QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#887259#2601. Lucky TicketsMatrixGroupAC ✓138ms3584kbC++231.5kb2025-02-07 16:13:082025-02-07 16:13:11

Judging History

This is the latest submission verdict.

  • [2025-02-07 16:13:11]
  • Judged
  • Verdict: AC
  • Time: 138ms
  • Memory: 3584kb
  • [2025-02-07 16:13:08]
  • Submitted

answer

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,del##i##verme=int(n);i<del##i##verme;++i)
#define rep1(i,n) for(int i=1,parano##i##a=int(n);i<=parano##i##a;++i)
#define per(i,n) for(int i=int(n)-1;i>=0;--i)
#define per1(i,n) for(int i=int(n);i>=1;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define y0 LingLuo
#define y1 VividCycle
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldb;
using namespace std;
const ll mod1=998244353;
const ll mod2=1000000007;
unsigned time_related_rand()
{
	return unsigned(std::chrono::steady_clock::now().time_since_epoch().count());
}
int n,s,q;
ll ans;
ll qkpw(ll a,ll b)
{
	ll r=1;while(b)
	{
		if(b&1)r=r*a%n;
		a=a*a%n;
		b>>=1;
	}
	return r;
}
int main()
{
	cin>>n>>s>>q;
	for(int i=0;i<n;++i)
	{
		if((qkpw(i,q)+(1ll*i*q))%n==s) ans+=i;
	}
	cout<<ans%q<<'\n';
	return 0;
}
/* things to check
1.  int overflow or long long memory need
2.  recursion/array/binary search/dp/loop bounds
3.  precision
4.  special cases(n=1,bounds)
5.  delete debug statements
6.  initialize(especially multi-tests)
7.  = or == , n or m ,++ or -- , i or j , > or >= , < or <=
8.  keep it simple and stupid
9.  do not delete, use // instead
10. operator priority
11. is there anything extra to output?
12. ...
*/

/* something to think about
1. greedy? dp? searching? dp with matrix/ segment tree? binary search?
2. If contains "not", why not ?????? or few affect?
*/

詳細信息

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: 0ms
memory: 3584kb

input:

3 2 3

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 1ms
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: 1ms
memory: 3584kb

input:

4 2 3

output:

2

result:

ok 1 number(s): "2"

Test #7:

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

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: 3584kb

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: 6ms
memory: 3456kb

input:

77263 13087 50147

output:

26904

result:

ok 1 number(s): "26904"

Test #13:

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

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: 3456kb

input:

1000000 394496 999983

output:

755554

result:

ok 1 number(s): "755554"

Test #16:

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

input:

1000000 24900 999451

output:

996185

result:

ok 1 number(s): "996185"

Test #17:

score: 0
Accepted
time: 131ms
memory: 3456kb

input:

999750 14190 999671

output:

191073

result:

ok 1 number(s): "191073"

Test #18:

score: 0
Accepted
time: 125ms
memory: 3456kb

input:

946312 10286 997741

output:

744939

result:

ok 1 number(s): "744939"

Test #19:

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

input:

997742 0 997741

output:

565729

result:

ok 1 number(s): "565729"

Test #20:

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

input:

977762 0 977761

output:

0

result:

ok 1 number(s): "0"