QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#133534 | #4932. Moon and Sun | wtn135687# | WA | 64ms | 32308kb | C++14 | 1.6kb | 2023-08-02 10:47:44 | 2023-08-02 10:47:45 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
const int N = 1e6+10,mo = 235813;
int a[N];
ll D[N],jc[N],invjc[N];
ll q_pow(ll a,ll b){
ll res=1;
while(b){
if(b&1)res=res*a%mo;
a=a*a%mo;
b>>=1;
}
return res;
}
ll inv(ll a){
return q_pow(a,mo-2);
}
ll C(ll n,ll m){
if(m>n||m<0||n<0)return 0;
ll ans=jc[n];
ans=ans*invjc[m]%mo;
ans=ans*invjc[n-m]%mo;
return ans;
}
void initzhs(){
D[2]=1;
for(int i=3;i<N;i++)D[i]=(i-1)*(D[i-1]+D[i-2])%mo;
D[0]=1;
jc[0]=1;
for(int i=1;i<N;i++)jc[i]=jc[i-1]*i%mo;
for(int i=0;i<N;i++)invjc[i]=inv(jc[i]);
}
int n;
int xs[N];
int pre[N];
bool check(int p){
int sum = (pre[p-1]+pre[n]-pre[p]+mo)%mo;
int m;
if(xs[p]>0)m=mo-sum;
else m=sum;
int x=abs(xs[p]);
if(x==0)return 0;
int ay=m*inv(x)%mo;
// cerr<<"ay="<<ay<<"\n";
if(ay>1e5&&mo-ay>1e5||ay==a[p])return 0;
return 1;
}
inline void solve(){
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=n;i++){
xs[i]=C(n-1,i-1);
if((n+i)%2==1)xs[i]*=-1;
}
for(int i=1;i<=n;i++){
if(xs[i]>0)pre[i]=(pre[i-1]+xs[i]*a[i]%mo)%mo;
else pre[i]=(pre[i-1]-(-xs[i])*a[i]%mo+mo)%mo;
}
int ans=0;
for(int i=1;i<=n;i++)if(check(i))ans++;
cout<<ans<<"\n";
}
signed main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
initzhs();
int WTN666=1;//cin>>WTN666;
while(WTN666--){
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 64ms
memory: 30044kb
input:
5 4 1 0 7 2
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 59ms
memory: 32204kb
input:
4 10 20 30 -40
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 60ms
memory: 32308kb
input:
2 100 100
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 52ms
memory: 30108kb
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: 0
Accepted
time: 60ms
memory: 30008kb
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:
334
result:
ok single line: '334'
Test #6:
score: 0
Accepted
time: 51ms
memory: 30052kb
input:
292 -99191 -98152 -98063 -98047 -97715 -97353 -97211 -96714 -94868 -94586 -93910 -92928 -91078 -90877 -89315 -88925 -88630 -87392 -87209 -86028 -84609 -84095 -83780 -83406 -83315 -82724 -82079 -81548 -81481 -81308 -80690 -80431 -79941 -76493 -75868 -75033 -74227 -74117 -73703 -73586 -73502 -73306 -7...
output:
248
result:
ok single line: '248'
Test #7:
score: -100
Wrong Answer
time: 56ms
memory: 30120kb
input:
309 98887 98493 98409 98076 97889 97105 96335 95922 95157 94858 94022 93801 93788 93600 93566 93431 92058 91804 90751 90382 90197 89866 89067 88948 88524 88049 87464 87356 85865 85383 85000 84838 84429 83352 81775 81241 80996 80303 79421 79359 79084 78979 78579 78311 77853 77615 77199 76350 75853 73...
output:
270
result:
wrong answer 1st lines differ - expected: '263', found: '270'