QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#352947#969. Discrete Logarithm is a JokeHKOI0#AC ✓552ms3784kbC++20615b2024-03-13 18:50:562024-03-13 18:50:57

Judging History

This is the latest submission verdict.

  • [2024-03-13 18:50:57]
  • Judged
  • Verdict: AC
  • Time: 552ms
  • Memory: 3784kb
  • [2024-03-13 18:50:56]
  • Submitted

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"