QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#909224#969. Discrete Logarithm is a JokeUrdAC ✓521ms3712kbC++17564b2025-02-21 17:11:482025-02-21 17:11:59

Judging History

This is the latest submission verdict.

  • [2025-02-21 17:11:59]
  • Judged
  • Verdict: AC
  • Time: 521ms
  • Memory: 3712kb
  • [2025-02-21 17:11:48]
  • Submitted

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"