QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#352947 | #969. Discrete Logarithm is a Joke | HKOI0# | AC ✓ | 552ms | 3784kb | C++20 | 615b | 2024-03-13 18:50:56 | 2024-03-13 18:50:57 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1'000'000'000'000'000'000 + 31;
ll power(ll a, ll b) {
ll ans = 1;
for(;b;b>>=1) {
if(b&1) ans=(__int128)ans*a%MOD;
a=(__int128)a*a%MOD;
}
return ans;
}
void solve() {
int n; cin >> n;
ll ans = 300;
while (n < 1000000) {
ans = power(42, ans);
n++;
}
cout << ans << '\n';
}
signed main() {
#ifndef LOCAL
ios::sync_with_stdio(false);
cin.tie(nullptr);
#endif
int T = 1;
// cin >> T;
while (T--) solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 543ms
memory: 3524kb
input:
0
output:
960002411612632915
result:
ok 1 number(s): "960002411612632915"
Test #2:
score: 0
Accepted
time: 544ms
memory: 3600kb
input:
1
output:
836174947389522544
result:
ok 1 number(s): "836174947389522544"
Test #3:
score: 0
Accepted
time: 385ms
memory: 3500kb
input:
300300
output:
263358264583736303
result:
ok 1 number(s): "263358264583736303"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
1000000
output:
300
result:
ok 1 number(s): "300"
Test #5:
score: 0
Accepted
time: 7ms
memory: 3600kb
input:
987654
output:
323040897684351053
result:
ok 1 number(s): "323040897684351053"
Test #6:
score: 0
Accepted
time: 552ms
memory: 3500kb
input:
2
output:
360265688540078138
result:
ok 1 number(s): "360265688540078138"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
999999
output:
580046907013163142
result:
ok 1 number(s): "580046907013163142"
Test #8:
score: 0
Accepted
time: 541ms
memory: 3540kb
input:
57136
output:
886385729914317304
result:
ok 1 number(s): "886385729914317304"
Test #9:
score: 0
Accepted
time: 275ms
memory: 3784kb
input:
511436
output:
649262956642775134
result:
ok 1 number(s): "649262956642775134"