QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#19841#2601. Lucky TicketsAppleblue17#WA 2ms3664kbC++11399b2022-02-12 10:56:512022-05-06 07:20:46

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:20:46]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3664kb
  • [2022-02-12 10:56:51]
  • 提交

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

Details

Tip: Click on the bar to expand more detailed information

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'