QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#499264#969. Discrete Logarithm is a Jokechengning0909AC ✓678ms3812kbC++14487b2024-07-31 10:47:002024-07-31 10:47:03

Judging History

This is the latest submission verdict.

  • [2024-07-31 10:47:03]
  • Judged
  • Verdict: AC
  • Time: 678ms
  • Memory: 3812kb
  • [2024-07-31 10:47:00]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using i128 = __int128;

const int N = 1e6, g = 42;
const ll mod = (ll)1e18 + 31;

int n;

ll qpow(int x, ll y) {
    if (!y) return 1;
    ll tmp = qpow(x, y / 2);
    return (i128)tmp * tmp % mod * (y & 1 ? x : 1) % mod;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    ll x = 300;
    for (int i = N - 1; i >= n; i--) x = qpow(g, x);
    cout << x;
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 678ms
memory: 3524kb

input:

0

output:

960002411612632915

result:

ok 1 number(s): "960002411612632915"

Test #2:

score: 0
Accepted
time: 676ms
memory: 3524kb

input:

1

output:

836174947389522544

result:

ok 1 number(s): "836174947389522544"

Test #3:

score: 0
Accepted
time: 474ms
memory: 3524kb

input:

300300

output:

263358264583736303

result:

ok 1 number(s): "263358264583736303"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

1000000

output:

300

result:

ok 1 number(s): "300"

Test #5:

score: 0
Accepted
time: 9ms
memory: 3544kb

input:

987654

output:

323040897684351053

result:

ok 1 number(s): "323040897684351053"

Test #6:

score: 0
Accepted
time: 675ms
memory: 3608kb

input:

2

output:

360265688540078138

result:

ok 1 number(s): "360265688540078138"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

999999

output:

580046907013163142

result:

ok 1 number(s): "580046907013163142"

Test #8:

score: 0
Accepted
time: 637ms
memory: 3592kb

input:

57136

output:

886385729914317304

result:

ok 1 number(s): "886385729914317304"

Test #9:

score: 0
Accepted
time: 382ms
memory: 3612kb

input:

511436

output:

649262956642775134

result:

ok 1 number(s): "649262956642775134"