QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#19842 | #2601. Lucky Tickets | Appleblue17# | WA | 2ms | 3716kb | C++11 | 457b | 2022-02-12 10:59:31 | 2022-05-06 07:20:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const long long N=1e6+5;
long long p,n,s,sum,ans;
long long ksm(long long a,long long x,long long mod){
long long 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(long long i=0,x=1;i<p;i++,x=x*n%p) sum=(sum+x)%p;
for(long long i=0;i<n;i++){
if((ksm(i,p,n)+i*p%n)%n==s) ans=(ans+1ll*sum*i%p)%p;
}
cout<<ans;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3572kb
input:
2 0 2
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 2ms
memory: 3580kb
input:
10 9 2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 2ms
memory: 3560kb
input:
3 2 3
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 0
Accepted
time: 2ms
memory: 3716kb
input:
2 1 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: -100
Wrong Answer
time: 2ms
memory: 3664kb
input:
4 0 3
output:
0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'