QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#19842#2601. Lucky TicketsAppleblue17#WA 2ms3716kbC++11457b2022-02-12 10:59:312022-05-06 07:20:49

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:49]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3716kb
  • [2022-02-12 10:59:31]
  • 提交

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'