QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#20463 | #2601. Lucky Tickets | The_Nobody# | AC ✓ | 318ms | 3660kb | C++14 | 1012b | 2022-02-16 10:27:49 | 2022-05-03 10:00:39 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define Il inline
#define Re register
#define mem(u,v) memset(u,v,sizeof(u))
#define rep(i,a,b) for(Re ll i=(a);i<=(b);i++)
#define drep(i,a,b) for(Re ll i=(a);i>=(b);i--)
#define go(u) for(ll i=head[u],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define writesp(x) write(x),putchar(' ')
#define writeln(x) write(x),puts("")
using namespace std;
Il ll read(){ll sum=0,f=0;char ch=getchar();for(;!isdigit(ch);ch=getchar())f|=(ch=='-');for(;isdigit(ch);ch=getchar())sum=((sum<<1)+(sum<<3)+(ch^48));return f?-sum:sum;}
void write(const ll x){if(x<0){putchar('-');write(-x);return;}if(x>9)write(x/10);putchar(x%10+'0');}
char getc(){char c=getchar();while(!isalpha(c))c=getchar();return c;}
#define N 310
ll n,s,p,sum;
ll mi(ll a,ll k,ll p){ll sum=1;for(;k;k>>=1,a=a*a%p)if(k&1)sum=sum*a%p;return sum;}
int main(){
n=read();s=read();p=read();
ll t=mi(2,p,p)-1;if(t<0)t+=p;
rep(i,0,n-1){
if((mi(i,p,n)+p*i)%n==s)sum+=i;
}
sum%=p;
writeln(sum*t%p);
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3532kb
input:
2 0 2
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 3ms
memory: 3584kb
input:
10 9 2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 2ms
memory: 3532kb
input:
3 2 3
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3528kb
input:
2 1 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 2ms
memory: 3584kb
input:
4 0 3
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
4 2 3
output:
2
result:
ok 1 number(s): "2"
Test #7:
score: 0
Accepted
time: 1ms
memory: 3580kb
input:
20 4 19
output:
5
result:
ok 1 number(s): "5"
Test #8:
score: 0
Accepted
time: 3ms
memory: 3568kb
input:
30 2 37
output:
23
result:
ok 1 number(s): "23"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
87 22 67
output:
0
result:
ok 1 number(s): "0"
Test #10:
score: 0
Accepted
time: 1ms
memory: 3564kb
input:
829 135 857
output:
803
result:
ok 1 number(s): "803"
Test #11:
score: 0
Accepted
time: 4ms
memory: 3660kb
input:
6120 2790 9851
output:
4622
result:
ok 1 number(s): "4622"
Test #12:
score: 0
Accepted
time: 22ms
memory: 3448kb
input:
77263 13087 50147
output:
26904
result:
ok 1 number(s): "26904"
Test #13:
score: 0
Accepted
time: 215ms
memory: 3516kb
input:
682298 437284 638801
output:
10038
result:
ok 1 number(s): "10038"
Test #14:
score: 0
Accepted
time: 246ms
memory: 3584kb
input:
823965 703789 575623
output:
483248
result:
ok 1 number(s): "483248"
Test #15:
score: 0
Accepted
time: 304ms
memory: 3584kb
input:
1000000 394496 999983
output:
755554
result:
ok 1 number(s): "755554"
Test #16:
score: 0
Accepted
time: 300ms
memory: 3640kb
input:
1000000 24900 999451
output:
996185
result:
ok 1 number(s): "996185"
Test #17:
score: 0
Accepted
time: 312ms
memory: 3564kb
input:
999750 14190 999671
output:
191073
result:
ok 1 number(s): "191073"
Test #18:
score: 0
Accepted
time: 296ms
memory: 3588kb
input:
946312 10286 997741
output:
744939
result:
ok 1 number(s): "744939"
Test #19:
score: 0
Accepted
time: 318ms
memory: 3584kb
input:
997742 0 997741
output:
565729
result:
ok 1 number(s): "565729"
Test #20:
score: 0
Accepted
time: 305ms
memory: 3568kb
input:
977762 0 977761
output:
0
result:
ok 1 number(s): "0"