QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#19852#2601. Lucky TicketsThe_Nobody#WA 4ms3580kbC++141.0kb2022-02-12 14:51:122022-05-06 07:21:40

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-06 07:21:40]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3580kb
  • [2022-02-12 14:51:12]
  • 提交

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);
}

Details

Tip: Click on the bar to expand more detailed information

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'