QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#887446#2601. Lucky TicketskunnitaimeiAC ✓137ms3712kbC++141.1kb2025-02-07 17:18:312025-02-07 17:18:38

Judging History

This is the latest submission verdict.

  • [2025-02-07 17:18:38]
  • Judged
  • Verdict: AC
  • Time: 137ms
  • Memory: 3712kb
  • [2025-02-07 17:18:31]
  • Submitted

answer

#include <bits/stdc++.h>
#define IOS() ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int long long
#define fir first
#define se second
#define pb(x) push_back(x)
#define pii pair<int,int>
#define all(a) (a).begin(),(a).end()
#define mp(a,b) make_pair(a,b)
using namespace std;
int lowbit(int x){
	return x&-x;
}
#define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++
char buf[1000000], *p1=buf,*p2=buf;
template <typename T>
void read(T &x){
	x=0;int f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())
	if(c=='-')f=-f;
	for(;c>='0'&&c<='9';c=getchar())
	x=x*10+c-'0';x*=f;
}
template <typename T, typename... Args>
void read(T &x, Args &...y){
	read(x);
	read(y...);
}
bool cmp(int x,int y){
	return x>y;
}
int n,s,q,ans;
int qpow(int a,int b){
	int res=1;
	while(b){
		if(b&1)
			res=res*a%n;
		a=a*a%n;
		b>>=1;
	}
	return res;
}
signed main(){
	//freopen("文件名.in","r",stdin);
	//freopen("文件名.out","w",stdout);
	IOS();
	cin>>n>>s>>q;
	for(int i=0;i<n;i++)
		if((qpow(i,q)+i*q)%n==s)
			ans+=i;
	cout<<ans%q<<"\n";
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3584kb

input:

2 0 2

output:

0

result:

ok 1 number(s): "0"

Test #2:

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

input:

10 9 2

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

3 2 3

output:

2

result:

ok 1 number(s): "2"

Test #4:

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

input:

2 1 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

4 0 3

output:

1

result:

ok 1 number(s): "1"

Test #6:

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

input:

4 2 3

output:

2

result:

ok 1 number(s): "2"

Test #7:

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

input:

20 4 19

output:

5

result:

ok 1 number(s): "5"

Test #8:

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

input:

30 2 37

output:

23

result:

ok 1 number(s): "23"

Test #9:

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

input:

87 22 67

output:

0

result:

ok 1 number(s): "0"

Test #10:

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

input:

829 135 857

output:

803

result:

ok 1 number(s): "803"

Test #11:

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

input:

6120 2790 9851

output:

4622

result:

ok 1 number(s): "4622"

Test #12:

score: 0
Accepted
time: 7ms
memory: 3584kb

input:

77263 13087 50147

output:

26904

result:

ok 1 number(s): "26904"

Test #13:

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

input:

682298 437284 638801

output:

10038

result:

ok 1 number(s): "10038"

Test #14:

score: 0
Accepted
time: 89ms
memory: 3584kb

input:

823965 703789 575623

output:

483248

result:

ok 1 number(s): "483248"

Test #15:

score: 0
Accepted
time: 128ms
memory: 3584kb

input:

1000000 394496 999983

output:

755554

result:

ok 1 number(s): "755554"

Test #16:

score: 0
Accepted
time: 123ms
memory: 3584kb

input:

1000000 24900 999451

output:

996185

result:

ok 1 number(s): "996185"

Test #17:

score: 0
Accepted
time: 132ms
memory: 3584kb

input:

999750 14190 999671

output:

191073

result:

ok 1 number(s): "191073"

Test #18:

score: 0
Accepted
time: 124ms
memory: 3584kb

input:

946312 10286 997741

output:

744939

result:

ok 1 number(s): "744939"

Test #19:

score: 0
Accepted
time: 137ms
memory: 3584kb

input:

997742 0 997741

output:

565729

result:

ok 1 number(s): "565729"

Test #20:

score: 0
Accepted
time: 129ms
memory: 3584kb

input:

977762 0 977761

output:

0

result:

ok 1 number(s): "0"