QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#131223 | #4932. Moon and Sun | arnold518# | WA | 1ms | 3892kb | C++17 | 852b | 2023-07-26 18:54:20 | 2023-07-26 18:54:22 |
Judging History
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'