QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#131226#4932. Moon and Sunarnold518#WA 1ms3888kbC++17831b2023-07-26 19:02:532023-07-26 19:02:56

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 19:02:56]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3888kb
  • [2023-07-26 19:02:53]
  • 提交

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]);

	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: 3736kb

input:

5
4 1 0 7 2

output:

3

result:

ok single line: '3'

Test #2:

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

input:

4
10 20 30 -40

output:

4

result:

ok single line: '4'

Test #3:

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

input:

2
100 100

output:

0

result:

ok single line: '0'

Test #4:

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

input:

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

output:

14

result:

ok single line: '14'

Test #5:

score: -100
Wrong Answer
time: 1ms
memory: 3668kb

input:

392
23531 -70064 22423 -55534 23391 -22700 88756 80526 36369 -10007 -28096 22617 -12591 80476 39531 -80144 -87955 93969 33358 30633 34132 -65817 -57922 -28367 -74214 50143 -36912 21570 -27256 -34989 14043 -92315 -12277 26859 97682 91797 -79591 30563 -58224 27016 -67737 99067 30626 16374 -49340 -1712...

output:

320

result:

wrong answer 1st lines differ - expected: '334', found: '320'