QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#212904 | #2601. Lucky Tickets | Days_of_Future_Past# | AC ✓ | 137ms | 3588kb | C++20 | 499b | 2023-10-13 22:34:26 | 2023-10-13 22:34:27 |
Judging History
answer
#include <bits/stdc++.h>
#define SZ(c) ((int)(c).size())
#define ALL(c) begin(c), end(c)
using namespace std;
typedef long long ll;
ll n, s, q;
ll pw(ll x, ll k) {
ll res = 1 % n;
for (ll bs = x; k > 0; k /= 2, bs = (bs * bs) % n)
if (k & 1)
res = (res * bs) % n;
return res;
}
int main() {
cin >> n >> s >> q;
ll ans = 0;
for (ll a = 0; a < n; ++a) {
if ((pw(a, q) + q * a) % n == s)
ans = (ans + a) % q;
}
cout << ans << endl;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3584kb
input:
2 0 2
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3356kb
input:
10 9 2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3364kb
input:
3 2 3
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3348kb
input:
2 1 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3380kb
input:
4 0 3
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3352kb
input:
4 2 3
output:
2
result:
ok 1 number(s): "2"
Test #7:
score: 0
Accepted
time: 1ms
memory: 3352kb
input:
20 4 19
output:
5
result:
ok 1 number(s): "5"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
30 2 37
output:
23
result:
ok 1 number(s): "23"
Test #9:
score: 0
Accepted
time: 1ms
memory: 3428kb
input:
87 22 67
output:
0
result:
ok 1 number(s): "0"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
829 135 857
output:
803
result:
ok 1 number(s): "803"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
6120 2790 9851
output:
4622
result:
ok 1 number(s): "4622"
Test #12:
score: 0
Accepted
time: 7ms
memory: 3380kb
input:
77263 13087 50147
output:
26904
result:
ok 1 number(s): "26904"
Test #13:
score: 0
Accepted
time: 83ms
memory: 3348kb
input:
682298 437284 638801
output:
10038
result:
ok 1 number(s): "10038"
Test #14:
score: 0
Accepted
time: 96ms
memory: 3472kb
input:
823965 703789 575623
output:
483248
result:
ok 1 number(s): "483248"
Test #15:
score: 0
Accepted
time: 128ms
memory: 3588kb
input:
1000000 394496 999983
output:
755554
result:
ok 1 number(s): "755554"
Test #16:
score: 0
Accepted
time: 123ms
memory: 3384kb
input:
1000000 24900 999451
output:
996185
result:
ok 1 number(s): "996185"
Test #17:
score: 0
Accepted
time: 132ms
memory: 3432kb
input:
999750 14190 999671
output:
191073
result:
ok 1 number(s): "191073"
Test #18:
score: 0
Accepted
time: 125ms
memory: 3584kb
input:
946312 10286 997741
output:
744939
result:
ok 1 number(s): "744939"
Test #19:
score: 0
Accepted
time: 137ms
memory: 3476kb
input:
997742 0 997741
output:
565729
result:
ok 1 number(s): "565729"
Test #20:
score: 0
Accepted
time: 132ms
memory: 3388kb
input:
977762 0 977761
output:
0
result:
ok 1 number(s): "0"