QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#909224 | #969. Discrete Logarithm is a Joke | Urd | AC ✓ | 521ms | 3712kb | C++17 | 564b | 2025-02-21 17:11:48 | 2025-02-21 17:11:59 |
Judging History
answer
#include <bits/stdc++.h>
#define ALL(v) begin(v), end(v)
using i64 = int64_t;
using i128 = __int128;
const i64 kMod = static_cast<i64>(1E18) + 31;
auto Power(i64 a, i64 b, i64 p = kMod) {
i64 r = 1;
for (; b; b >>= 1, a = i128{a} * a % p) {
if (b & 1) r = i128{r} * a % p;
}
return r;
}
int n;
i64 a = 300;
auto main() -> int {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr), std::cout.tie(nullptr);
std::cin >> n;
for (int i = n; i < 1E6; ++i) a = Power(42, a);
std::cout << a << '\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 521ms
memory: 3712kb
input:
0
output:
960002411612632915
result:
ok 1 number(s): "960002411612632915"
Test #2:
score: 0
Accepted
time: 517ms
memory: 3584kb
input:
1
output:
836174947389522544
result:
ok 1 number(s): "836174947389522544"
Test #3:
score: 0
Accepted
time: 365ms
memory: 3584kb
input:
300300
output:
263358264583736303
result:
ok 1 number(s): "263358264583736303"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
1000000
output:
300
result:
ok 1 number(s): "300"
Test #5:
score: 0
Accepted
time: 7ms
memory: 3584kb
input:
987654
output:
323040897684351053
result:
ok 1 number(s): "323040897684351053"
Test #6:
score: 0
Accepted
time: 518ms
memory: 3712kb
input:
2
output:
360265688540078138
result:
ok 1 number(s): "360265688540078138"
Test #7:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
999999
output:
580046907013163142
result:
ok 1 number(s): "580046907013163142"
Test #8:
score: 0
Accepted
time: 493ms
memory: 3584kb
input:
57136
output:
886385729914317304
result:
ok 1 number(s): "886385729914317304"
Test #9:
score: 0
Accepted
time: 253ms
memory: 3584kb
input:
511436
output:
649262956642775134
result:
ok 1 number(s): "649262956642775134"