QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#276731 | #3267. 分手是祝愿 | SoyTony | 100 ✓ | 24ms | 4892kb | C++14 | 1.4kb | 2023-12-06 10:09:10 | 2023-12-06 10:09:10 |
Judging History
answer
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int maxn=3e5+10;
const int maxm=1e6+10;
const ll mod=1e5+3;
const ll base=1e8;
const ull base1=233;
const ull base2=19260817;
const int maxxn=0x7fffffff;
const int minxn=-0x7fffffff;
const db inf=1e13;
const db eps=1e-9;
inline int read(){
int x=0,w=1;char c=getchar();
while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}
while(c<='9'&&c>='0'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
return x*w;
}
int n,k;
int a[maxn];
int cnt;
ll dp[maxn],ans;
inline ll q_pow(ll x,int p){
ll ans=1;
while(p){
if(p&1){
ans=ans*x%mod;
}
x=x*x%mod;
p>>=1;
}
return ans;
}
int main(){
n=read(),k=read();
for(int i=1;i<=n;i++){
a[i]=read();
}
for(int i=n;i>=1;i--){
if(a[i]){
cnt++;
for(int j=1;j*j<=i;j++){
if(i%j==0){
a[j]^=1;
if(j*j!=i) a[i/j]^=1;
}
}
}
}
dp[n+1]=0;
for(int i=n;i>=1;i--){
dp[i]=(n+dp[i+1]*(n-i)%mod)%mod;
dp[i]=dp[i]*q_pow(i,mod-2)%mod;
}
if(cnt<=k) ans=cnt;
else{
for(int i=cnt;i>k;i--){
ans=(ans+dp[i])%mod;
}
ans=(ans+k)%mod;
}
for(int i=1;i<=n;i++){
ans=(ans*i)%mod;
}
printf("%lld\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 5
Accepted
time: 0ms
memory: 3764kb
input:
4 4 0 1 1 0
output:
48
result:
ok single line: '48'
Test #2:
score: 5
Accepted
time: 0ms
memory: 3800kb
input:
4 3 1 1 1 0
output:
72
result:
ok single line: '72'
Test #3:
score: 5
Accepted
time: 0ms
memory: 3884kb
input:
6 6 1 1 1 1 1 1
output:
3600
result:
ok single line: '3600'
Test #4:
score: 5
Accepted
time: 0ms
memory: 3808kb
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: 3952kb
input:
5 5 0 1 0 0 1
output:
240
result:
ok single line: '240'
Test #6:
score: 5
Accepted
time: 0ms
memory: 3952kb
input:
5 3 0 0 0 0 0
output:
0
result:
ok single line: '0'
Test #7:
score: 5
Accepted
time: 0ms
memory: 3732kb
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: 3960kb
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: 0ms
memory: 3816kb
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: 0ms
memory: 3760kb
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: 0ms
memory: 3760kb
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: 3956kb
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: 0ms
memory: 3808kb
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: 0ms
memory: 3820kb
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: 0ms
memory: 3784kb
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: 0ms
memory: 3892kb
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: 1ms
memory: 3988kb
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: 15ms
memory: 4572kb
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: 14ms
memory: 4520kb
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: 24ms
memory: 4892kb
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'