QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#19852 | #2601. Lucky Tickets | The_Nobody# | WA | 4ms | 3580kb | C++14 | 1.0kb | 2022-02-12 14:51:12 | 2022-05-06 07:21:40 |
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,1,n){
if((mi(i,p,n)+p*i)%n==s)sum+=i;
}
// cout<<sum<<endl;
sum%=p;
writeln(sum*t%p);
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 3564kb
input:
2 0 2
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 4ms
memory: 3580kb
input:
10 9 2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 3ms
memory: 3568kb
input:
3 2 3
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
2 1 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: -100
Wrong Answer
time: 3ms
memory: 3556kb
input:
4 0 3
output:
2
result:
wrong answer 1st numbers differ - expected: '1', found: '2'