QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#96068#969. Discrete Logarithm is a JokeAPJifengcAC ✓2724ms3692kbC++14479b2023-04-13 08:35:152023-04-13 08:35:17

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-13 08:35:17]
  • Judged
  • Verdict: AC
  • Time: 2724ms
  • Memory: 3692kb
  • [2023-04-13 08:35:15]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
const long long P = 1000000000000000031;
long long qpow(__int128_t a, long long b) {
    __int128_t ans = 1;
    while (b) {
        if (b & 1) ans = ans * a % P;
        a = a * a % P;
        b >>= 1;
    }
    return ans;
}
int n;
int main() {
    scanf("%d", &n);
    n = 1000000 - n;
    long long ans = 300;
    while (n--) {
        ans = qpow(42, ans);
    }
    printf("%lld\n", ans);
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2724ms
memory: 3632kb

input:

0

output:

960002411612632915

result:

ok 1 number(s): "960002411612632915"

Test #2:

score: 0
Accepted
time: 2720ms
memory: 3680kb

input:

1

output:

836174947389522544

result:

ok 1 number(s): "836174947389522544"

Test #3:

score: 0
Accepted
time: 1903ms
memory: 3584kb

input:

300300

output:

263358264583736303

result:

ok 1 number(s): "263358264583736303"

Test #4:

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

input:

1000000

output:

300

result:

ok 1 number(s): "300"

Test #5:

score: 0
Accepted
time: 35ms
memory: 3680kb

input:

987654

output:

323040897684351053

result:

ok 1 number(s): "323040897684351053"

Test #6:

score: 0
Accepted
time: 2719ms
memory: 3640kb

input:

2

output:

360265688540078138

result:

ok 1 number(s): "360265688540078138"

Test #7:

score: 0
Accepted
time: 2ms
memory: 3648kb

input:

999999

output:

580046907013163142

result:

ok 1 number(s): "580046907013163142"

Test #8:

score: 0
Accepted
time: 2564ms
memory: 3624kb

input:

57136

output:

886385729914317304

result:

ok 1 number(s): "886385729914317304"

Test #9:

score: 0
Accepted
time: 1328ms
memory: 3680kb

input:

511436

output:

649262956642775134

result:

ok 1 number(s): "649262956642775134"