QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#108516 | #2601. Lucky Tickets | zghtyarecrenj | WA | 2ms | 3540kb | C++14 | 459b | 2023-05-25 13:35:07 | 2023-05-25 13:35:10 |
Judging History
answer
#include <bits/stdc++.h>
using ll = long long;
inline ll qpow(ll x, ll y, ll p) {
ll z = 1;
for (; y; y >>= 1, x = x * x % p)
if (y & 1) z = z * x % p;
return z;
}
ll n, s, q;
int main() {
std::ios::sync_with_stdio(false);
std::cin >> n >> s >> q;
ll res = 0;
for (ll i = 0; i < n; ++i) {
ll t = i * (qpow(2, q, q) + q - 1) % q;
if (s == (qpow(i, q, n) + q * i) % n) res += t;
}
std::cout << res << '\n';
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3432kb
input:
2 0 2
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3436kb
input:
10 9 2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 2ms
memory: 3300kb
input:
3 2 3
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 0
Accepted
time: 2ms
memory: 3348kb
input:
2 1 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 2ms
memory: 3540kb
input:
4 0 3
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: 0
Accepted
time: 1ms
memory: 3424kb
input:
4 2 3
output:
2
result:
ok 1 number(s): "2"
Test #7:
score: -100
Wrong Answer
time: 1ms
memory: 3536kb
input:
20 4 19
output:
24
result:
wrong answer 1st numbers differ - expected: '5', found: '24'