QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#372488 | #3267. 分手是祝愿 | RDFZchenyy | 100 ✓ | 34ms | 5720kb | C++14 | 1.1kb | 2024-03-31 14:06:34 | 2024-03-31 14:06:35 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100005
long long n,k;
long long a[MAXN];
long long g[MAXN];
long long f[MAXN];
const long long mod=100003;
long long fpow(long long a,long long b,long long p){
long long ret=1;
for(;b;b>>=1,a*=a,a%=p){
if(b&1){
ret*=a; ret%=p;
}
}
return ret;
}
long long fpow(long long a,long long b){
return fpow(a,b,mod);
}
long long inv(long long x){
return fpow(x,mod-2);
}
int main(){
ios::sync_with_stdio(false);
cin>>n>>k;
for(long long i=1;i<=n;i++){
cin>>a[i];
}
long long ans=0;
for(long long i=n;i>=1;i--){
if(a[i]){
ans++;
for(long long j=1;j<=sqrt(i);j++){
if(i%j==0){
a[j]^=1;
if(j!=(i/j)){
a[i/j]^=1;
}
}
}
}
}
g[n]=1;
for(long long i=n-1;i>=k+1;i--){
g[i]=(n-i)*inv(i)*g[i+1]+n*inv(i);
g[i]%=mod;
}
for(long long i=1;i<=k;i++){
f[i]=i;
}
for(long long i=k+1;i<=n;i++){
f[i]=f[i-1]+g[i];
}
for(long long i=1;i<=n;i++){
f[ans]=(f[ans]*i)%mod;
}
cout<<f[ans]<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 5
Accepted
time: 1ms
memory: 3548kb
input:
4 4 0 1 1 0
output:
48
result:
ok single line: '48'
Test #2:
score: 5
Accepted
time: 1ms
memory: 3556kb
input:
4 3 1 1 1 0
output:
72
result:
ok single line: '72'
Test #3:
score: 5
Accepted
time: 0ms
memory: 3628kb
input:
6 6 1 1 1 1 1 1
output:
3600
result:
ok single line: '3600'
Test #4:
score: 5
Accepted
time: 0ms
memory: 3588kb
input:
7 1 0 0 1 1 0 1 1
output:
55229
result:
ok single line: '55229'
Test #5:
score: 5
Accepted
time: 0ms
memory: 3560kb
input:
5 5 0 1 0 0 1
output:
240
result:
ok single line: '240'
Test #6:
score: 5
Accepted
time: 0ms
memory: 3692kb
input:
5 3 0 0 0 0 0
output:
0
result:
ok single line: '0'
Test #7:
score: 5
Accepted
time: 0ms
memory: 3620kb
input:
39 39 1 0 1 0 0 0 0 0 0 0 1 1 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 0 1 1 1 1 0 0 1 0 1 1 0
output:
3958
result:
ok single line: '3958'
Test #8:
score: 5
Accepted
time: 0ms
memory: 3616kb
input:
45 34 0 0 0 1 1 0 1 1 0 0 0 0 1 0 0 0 1 0 1 1 1 0 1 0 1 0 0 1 1 0 0 0 0 0 0 1 1 1 0 1 0 0 0 0 1
output:
58701
result:
ok single line: '58701'
Test #9:
score: 5
Accepted
time: 1ms
memory: 5720kb
input:
62 62 1 1 1 1 0 1 1 0 0 0 1 0 0 1 0 1 1 0 1 0 1 1 0 0 0 0 1 0 1 0 0 0 1 1 0 1 1 1 1 0 0 1 0 0 1 1 1 0 0 1 0 1 1 0 1 0 0 1 0 0 0 1
output:
74689
result:
ok single line: '74689'
Test #10:
score: 5
Accepted
time: 1ms
memory: 3624kb
input:
9 3 0 0 0 0 1 0 0 0 0
output:
25739
result:
ok single line: '25739'
Test #11:
score: 5
Accepted
time: 1ms
memory: 5632kb
input:
503 503 1 1 1 0 1 0 0 1 1 0 1 1 0 1 0 0 1 1 1 0 0 1 1 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 1 1 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 1 0 1 0 0 0 1 0 0 0 1 0 1 1 0 1 0 0 0 1 0 0 1 1 0 1 1 0 1 0 1 1 0 0 0 1 0 1 1 0 0 1 0 1 1 1 1 1 0 0 1 0 1 0 0 ...
output:
7933
result:
ok single line: '7933'
Test #12:
score: 5
Accepted
time: 0ms
memory: 3584kb
input:
962 658 0 0 0 1 1 1 0 0 1 1 1 0 0 0 1 0 0 1 1 1 1 0 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 0 0 1 0 1 1 1 1 0 1 0 1 1 0 0 1 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 0 1 1 1 0 1 0 1 0 0 0 0 0 1 1 0 1 1 1 1 0 0 0 0 0 1 1 1 0 1 1 1 1 0 1 1 0 1 1 0 0 1 0 0 0 0 0 1 0 1 1 0 1 0 1 0 0 0 1 1 0 1 1 1 0 0 0 0 1 1 0 ...
output:
55348
result:
ok single line: '55348'
Test #13:
score: 5
Accepted
time: 1ms
memory: 3632kb
input:
724 724 0 1 0 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 0 1 0 0 0 0 1 0 0 1 0 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0 0 0 1 1 0 1 1 1 0 1 1 0 1 1 0 1 0 1 1 1 0 1 0 0 1 0 0 1 0 0 1 0 1 1 0 1 0 1 1 1 0 1 1 0 1 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 0 1 0 1 0 1 1 1 1 0 0 1 0 1 1 1 0 1 1 1 0 0 0 0 1 1 1 1 1 ...
output:
69048
result:
ok single line: '69048'
Test #14:
score: 5
Accepted
time: 1ms
memory: 3696kb
input:
881 9 1 0 1 1 1 1 0 0 1 0 0 0 0 0 1 0 0 1 1 0 1 0 1 0 0 1 1 0 0 1 1 1 1 1 1 0 1 0 1 1 1 1 0 1 1 1 0 1 0 0 1 0 0 0 1 1 0 0 1 1 0 0 1 0 1 0 0 0 1 1 1 0 0 0 1 1 0 0 1 1 0 1 1 1 0 0 0 0 1 1 0 1 1 0 1 0 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 1 1 0 1 0 1 1 1 0 1 0 0 0 1 1 1 1 1 0 0 1 1 1 0 0 0 1 1 0 0 1 1 0 0 1 ...
output:
95266
result:
ok single line: '95266'
Test #15:
score: 5
Accepted
time: 1ms
memory: 3588kb
input:
668 668 1 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0 1 0 1 1 1 0 1 0 1 0 1 0 1 0 0 1 0 0 0 0 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 0 1 1 0 1 0 1 1 1 1 1 0 1 1 0 1 1 0 1 1 1 0 1 1 0 1 1 0 0 1 0 1 1 1 0 0 0 1 1 1 1 1 0 1 1 1 1 0 1 0 0 0 1 0 1 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1 1 0 0 1 1 1 1 1 1 0 1 0 0 1 0 1 1 0 0 0 1 1 0 ...
output:
33628
result:
ok single line: '33628'
Test #16:
score: 5
Accepted
time: 1ms
memory: 3632kb
input:
505 3 0 0 1 1 0 0 1 0 1 1 0 1 0 0 1 1 1 0 0 0 0 1 1 0 0 0 1 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 0 1 0 0 0 0 0 0 1 1 1 0 1 1 0 1 0 0 1 0 1 1 1 1 0 0 0 1 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 0 1 0 0 1 0 0 1 1 1 1 1 0 1 1 1 1 0 1 0 1 0 1 0 0 1 0 1 0 0 0 0 1 1 1 0 0 0 0 0 1 0 1 0 1 1 0 1 0 1 ...
output:
75577
result:
ok single line: '75577'
Test #17:
score: 5
Accepted
time: 2ms
memory: 3724kb
input:
8933 8933 0 0 1 1 0 0 0 1 1 0 1 1 0 0 1 0 1 1 1 0 1 0 0 1 1 0 0 0 1 1 1 0 1 1 0 0 1 0 1 1 0 1 0 1 1 0 1 1 0 1 0 1 1 0 0 1 0 0 0 1 0 0 0 1 1 1 1 1 0 0 1 1 0 0 0 1 1 1 1 1 0 1 0 0 0 1 0 1 1 0 0 0 1 0 0 1 1 1 1 0 1 0 0 1 1 0 0 0 1 0 1 0 0 0 1 0 0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 1 0 0 0 0 0 0 ...
output:
31893
result:
ok single line: '31893'
Test #18:
score: 5
Accepted
time: 23ms
memory: 5068kb
input:
63525 7516 1 1 0 0 1 1 1 0 0 0 0 0 0 0 1 1 0 1 0 0 1 0 0 0 0 1 1 1 1 1 0 1 1 1 1 1 0 1 0 1 0 1 1 0 0 1 0 1 0 1 1 0 0 1 1 0 0 1 0 0 1 0 0 1 1 0 1 0 1 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 1 1 1 0 0 0 0 0 1 1 0 1 1 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 1 0 1 0 0 1 1 0 1 1 1 0 1 1 1 1 0 0 0 1 1 0 1 0 0 0 1 0 0 1 0 1...
output:
38712
result:
ok single line: '38712'
Test #19:
score: 5
Accepted
time: 21ms
memory: 4648kb
input:
64931 64931 1 1 0 1 1 1 0 0 1 0 1 1 0 1 1 1 0 1 0 1 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 1 0 0 1 1 0 0 0 0 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 0 1 0 0 1 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 1 1 0 1 0 0 1 0 1 0 0 1 0 1 1 0 1 1 0 0 1 1 0 0 0 0 1 0 1 0 0 1 1 0 1 1 0 1 0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 0 0 1 0 1 0 0 1 0 ...
output:
12510
result:
ok single line: '12510'
Test #20:
score: 5
Accepted
time: 34ms
memory: 5412kb
input:
96495 72757 1 0 0 1 1 0 0 0 1 0 0 1 0 1 1 1 1 1 0 1 0 1 0 0 1 0 1 1 0 1 0 1 1 1 1 0 0 0 1 0 0 1 1 0 0 1 0 1 1 1 0 1 1 1 1 1 1 0 0 1 0 1 0 0 0 0 1 0 1 1 0 0 1 1 0 0 1 0 0 1 1 0 1 0 0 0 0 1 1 1 0 1 0 0 0 1 0 0 1 0 0 0 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 1 0 1 1 0 1 1 0 0 1 1 1 1 1 0 1 0 0 0 0 1 0 1 0 1 ...
output:
71132
result:
ok single line: '71132'