QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#19841 | #2601. Lucky Tickets | Appleblue17# | WA | 2ms | 3664kb | C++11 | 399b | 2022-02-12 10:56:51 | 2022-05-06 07:20:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int p,n,s,sum,ans;
int ksm(int a,int x,int mod){
int tot=1;
while(x){
if(x & 1) tot=1ll*tot*a%mod;
a=1ll*a*a%mod;
x>>=1;
}
return tot;
}
int main(){
cin>>n>>s>>p;
for(int i=0,x=1;i<p;i++,x=x*n%p) sum=(sum+x)%p;
for(int i=0;i<n;i++){
if((ksm(i,p,n)+i*p%n)%n==s) ans=(ans+sum*i%p)%p;
}
cout<<ans;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3660kb
input:
2 0 2
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 2ms
memory: 3584kb
input:
10 9 2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
3 2 3
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3588kb
input:
2 1 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3568kb
input:
4 0 3
output:
0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'