QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#131223#4932. Moon and Sunarnold518#WA 1ms3892kbC++17852b2023-07-26 18:54:202023-07-26 18:54:22

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-26 18:54:22]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3892kb
  • [2023-07-26 18:54:20]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5;
const ll MOD = 235813;

int N, A[MAXN+10], B[MAXN+10];

ll mypow(ll x, ll y)
{
	ll ret=1;
	while(y)
	{
		if(y&1) ret=ret*x%MOD;
		y>>=1; x=x*x%MOD;
	}
	return ret;
}

ll inv(ll x) { return mypow(x, MOD-2); }

int main()
{
	scanf("%d", &N);
	for(int i=1; i<=N; i++) scanf("%d", &A[i]), A[i]=(A[i]+MOD)%MOD;

	B[N]=1;
	ll sum=0;
	for(int i=N-1; i>=1; i--)
	{
		B[i]=B[i+1]*(MOD-1)%MOD*i%MOD*inv(N-i)%MOD;
	}

	for(int i=1; i<=N; i++) sum=(sum+B[i]*A[i])%MOD;

	int ans=0;
	for(int i=1; i<=N; i++)
	{
		ll t=((A[i]*B[i]-sum)%MOD+MOD)%MOD;
		ll v=t*inv(B[i])%MOD;
		ll x=100000;
		if(v>x) v-=MOD;
		if(-x<=v && v<=x && v!=A[i]) ans++;
	}
	printf("%d\n", ans);
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3880kb

input:

5
4 1 0 7 2

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3884kb

input:

4
10 20 30 -40

output:

4

result:

ok single line: '4'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3892kb

input:

2
100 100

output:

0

result:

ok single line: '0'

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3664kb

input:

16
19 43 69 21 72 9 70 -15 25 29 -23 -13 -41 79 -89 93

output:

12

result:

wrong answer 1st lines differ - expected: '14', found: '12'