QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#19840 | #2601. Lucky Tickets | wxp# | AC ✓ | 710ms | 50756kb | C++14 | 959b | 2022-02-12 10:46:44 | 2022-05-06 07:20:37 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define per(i,x,y) for(int i=x;i>=y;--i)
#define lon long long
using namespace std;
const int n7=3012345;
lon n,m,jz;
lon mul[n7],imul[n7],t,ans,mo;
int rd(){
int shu=0;bool fu=0;char ch=getchar();
while( !isdigit(ch) ){if(ch=='-')fu=1;ch=getchar();}
while( isdigit(ch) )shu=(shu<<1)+(shu<<3)+ch-'0',ch=getchar();
return fu?-shu:shu;
}
lon Dpow(lon p,lon q=mo-2){
lon tot=1;
while(q){
if(q&1)tot=tot*p%mo;
p=p*p%mo,q=q>>1;
}
return tot;
}
void ready(int wl){
mul[0]=1;
rep(i,1,wl)mul[i]=mul[i-1]*i%mo;
imul[wl]=Dpow(mul[wl]);
per(i,wl-1,0)imul[i]=imul[i+1]*(i+1)%mo;
}
int main(){
jz=rd(),m=rd(),n=mo=rd();
ready(3000000);
rep(i,0,n-1)t=( t+Dpow(2,i) )%mo;
rep(i,0,jz-1){
mo=jz;
lon tot=(Dpow(i,n)+1ll*i*n)%mo;
mo=n;
if(tot^m)continue;
ans=(ans+mul[i+n]*imul[i]%mo+i*t%mo)%mo;
}
printf("%lld",ans);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 95ms
memory: 50664kb
input:
2 0 2
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 100ms
memory: 50640kb
input:
10 9 2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 89ms
memory: 50640kb
input:
3 2 3
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 0
Accepted
time: 83ms
memory: 50668kb
input:
2 1 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 56ms
memory: 50652kb
input:
4 0 3
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: 0
Accepted
time: 84ms
memory: 50616kb
input:
4 2 3
output:
2
result:
ok 1 number(s): "2"
Test #7:
score: 0
Accepted
time: 67ms
memory: 50624kb
input:
20 4 19
output:
5
result:
ok 1 number(s): "5"
Test #8:
score: 0
Accepted
time: 85ms
memory: 50624kb
input:
30 2 37
output:
23
result:
ok 1 number(s): "23"
Test #9:
score: 0
Accepted
time: 86ms
memory: 50640kb
input:
87 22 67
output:
0
result:
ok 1 number(s): "0"
Test #10:
score: 0
Accepted
time: 100ms
memory: 50680kb
input:
829 135 857
output:
803
result:
ok 1 number(s): "803"
Test #11:
score: 0
Accepted
time: 88ms
memory: 50684kb
input:
6120 2790 9851
output:
4622
result:
ok 1 number(s): "4622"
Test #12:
score: 0
Accepted
time: 112ms
memory: 50640kb
input:
77263 13087 50147
output:
26904
result:
ok 1 number(s): "26904"
Test #13:
score: 0
Accepted
time: 476ms
memory: 50640kb
input:
682298 437284 638801
output:
10038
result:
ok 1 number(s): "10038"
Test #14:
score: 0
Accepted
time: 495ms
memory: 50632kb
input:
823965 703789 575623
output:
483248
result:
ok 1 number(s): "483248"
Test #15:
score: 0
Accepted
time: 679ms
memory: 50636kb
input:
1000000 394496 999983
output:
755554
result:
ok 1 number(s): "755554"
Test #16:
score: 0
Accepted
time: 665ms
memory: 50632kb
input:
1000000 24900 999451
output:
996185
result:
ok 1 number(s): "996185"
Test #17:
score: 0
Accepted
time: 690ms
memory: 50716kb
input:
999750 14190 999671
output:
191073
result:
ok 1 number(s): "191073"
Test #18:
score: 0
Accepted
time: 705ms
memory: 50756kb
input:
946312 10286 997741
output:
744939
result:
ok 1 number(s): "744939"
Test #19:
score: 0
Accepted
time: 696ms
memory: 50664kb
input:
997742 0 997741
output:
565729
result:
ok 1 number(s): "565729"
Test #20:
score: 0
Accepted
time: 710ms
memory: 50592kb
input:
977762 0 977761
output:
0
result:
ok 1 number(s): "0"