QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#20445#2601. Lucky TicketsAppleblue17#AC ✓348ms3712kbC++17460b2022-02-16 10:06:252022-05-03 09:56:05

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-03 09:56:05]
  • 评测
  • 测评结果:AC
  • 用时:348ms
  • 内存:3712kb
  • [2022-02-16 10:06:25]
  • 提交

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*2%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: 3ms
memory: 3444kb

input:

2 0 2

output:

0

result:

ok 1 number(s): "0"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

10 9 2

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

3 2 3

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 3ms
memory: 3532kb

input:

2 1 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 1ms
memory: 3564kb

input:

4 0 3

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: 0
Accepted
time: 2ms
memory: 3560kb

input:

4 2 3

output:

2

result:

ok 1 number(s): "2"

Test #7:

score: 0
Accepted
time: 2ms
memory: 3556kb

input:

20 4 19

output:

5

result:

ok 1 number(s): "5"

Test #8:

score: 0
Accepted
time: 3ms
memory: 3644kb

input:

30 2 37

output:

23

result:

ok 1 number(s): "23"

Test #9:

score: 0
Accepted
time: 2ms
memory: 3660kb

input:

87 22 67

output:

0

result:

ok 1 number(s): "0"

Test #10:

score: 0
Accepted
time: 3ms
memory: 3532kb

input:

829 135 857

output:

803

result:

ok 1 number(s): "803"

Test #11:

score: 0
Accepted
time: 5ms
memory: 3576kb

input:

6120 2790 9851

output:

4622

result:

ok 1 number(s): "4622"

Test #12:

score: 0
Accepted
time: 23ms
memory: 3552kb

input:

77263 13087 50147

output:

26904

result:

ok 1 number(s): "26904"

Test #13:

score: 0
Accepted
time: 230ms
memory: 3712kb

input:

682298 437284 638801

output:

10038

result:

ok 1 number(s): "10038"

Test #14:

score: 0
Accepted
time: 263ms
memory: 3592kb

input:

823965 703789 575623

output:

483248

result:

ok 1 number(s): "483248"

Test #15:

score: 0
Accepted
time: 332ms
memory: 3712kb

input:

1000000 394496 999983

output:

755554

result:

ok 1 number(s): "755554"

Test #16:

score: 0
Accepted
time: 321ms
memory: 3516kb

input:

1000000 24900 999451

output:

996185

result:

ok 1 number(s): "996185"

Test #17:

score: 0
Accepted
time: 338ms
memory: 3516kb

input:

999750 14190 999671

output:

191073

result:

ok 1 number(s): "191073"

Test #18:

score: 0
Accepted
time: 324ms
memory: 3532kb

input:

946312 10286 997741

output:

744939

result:

ok 1 number(s): "744939"

Test #19:

score: 0
Accepted
time: 343ms
memory: 3564kb

input:

997742 0 997741

output:

565729

result:

ok 1 number(s): "565729"

Test #20:

score: 0
Accepted
time: 348ms
memory: 3560kb

input:

977762 0 977761

output:

0

result:

ok 1 number(s): "0"