QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#393191 | #2601. Lucky Tickets | ucup-team2580# | AC ✓ | 254ms | 3740kb | C++23 | 1.0kb | 2024-04-18 11:44:14 | 2024-04-18 11:44:15 |
Judging History
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
ll ksm(ll a,ll b,ll mod)
{
ll ans=1;
while(b)
{
if(b&1) ans=ans*a%mod;
b>>=1;
a=a*a%mod;
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,s,q;
cin>>n>>s>>q;
ll ans=0;
for(int i=0;i<n;i++)
if((ksm(i,q,n)+1ll*i*q)%n==s)
ans=(ans+ksm(i,q,q))%q;
cout<<ans<<endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
input:
2 0 2
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
10 9 2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
3 2 3
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
2 1 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
4 0 3
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
4 2 3
output:
2
result:
ok 1 number(s): "2"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
20 4 19
output:
5
result:
ok 1 number(s): "5"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
30 2 37
output:
23
result:
ok 1 number(s): "23"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
87 22 67
output:
0
result:
ok 1 number(s): "0"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
829 135 857
output:
803
result:
ok 1 number(s): "803"
Test #11:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
6120 2790 9851
output:
4622
result:
ok 1 number(s): "4622"
Test #12:
score: 0
Accepted
time: 7ms
memory: 3656kb
input:
77263 13087 50147
output:
26904
result:
ok 1 number(s): "26904"
Test #13:
score: 0
Accepted
time: 84ms
memory: 3684kb
input:
682298 437284 638801
output:
10038
result:
ok 1 number(s): "10038"
Test #14:
score: 0
Accepted
time: 93ms
memory: 3688kb
input:
823965 703789 575623
output:
483248
result:
ok 1 number(s): "483248"
Test #15:
score: 0
Accepted
time: 130ms
memory: 3600kb
input:
1000000 394496 999983
output:
755554
result:
ok 1 number(s): "755554"
Test #16:
score: 0
Accepted
time: 126ms
memory: 3724kb
input:
1000000 24900 999451
output:
996185
result:
ok 1 number(s): "996185"
Test #17:
score: 0
Accepted
time: 134ms
memory: 3600kb
input:
999750 14190 999671
output:
191073
result:
ok 1 number(s): "191073"
Test #18:
score: 0
Accepted
time: 126ms
memory: 3672kb
input:
946312 10286 997741
output:
744939
result:
ok 1 number(s): "744939"
Test #19:
score: 0
Accepted
time: 157ms
memory: 3612kb
input:
997742 0 997741
output:
565729
result:
ok 1 number(s): "565729"
Test #20:
score: 0
Accepted
time: 254ms
memory: 3672kb
input:
977762 0 977761
output:
0
result:
ok 1 number(s): "0"