QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#91247#969. Discrete Logarithm is a JokenamelessguguguAC ✓2790ms1876kbC++14647b2023-03-27 21:17:142023-03-27 21:17: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-03-27 21:17:17]
  • Judged
  • Verdict: AC
  • Time: 2790ms
  • Memory: 1876kb
  • [2023-03-27 21:17:14]
  • Submitted

answer

#include <cstdio>
#include <cstring>
#include <algorithm>
#define FILEIO(filename) (freopen(filename ".in", "r", stdin), freopen(filename ".out", "w", stdout))
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
const ll mod = 1000000000000000031, G = 42;
int n;
inline ll qpow(ll x, ll y)
{
    ll res = 1;
    for (; y; y >>= 1, x = (lll)x * x % mod)
        if (y & 1)
            res = (lll)res * x % mod;
    return res;
}
int main(void)
{
    scanf("%d", &n), n = 1000000 - n;
    ll st = 300;
    for (int i = 1;i <= n;++i)
        st = qpow(G, st);
    printf("%lld\n", st);
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2751ms
memory: 1632kb

input:

0

output:

960002411612632915

result:

ok 1 number(s): "960002411612632915"

Test #2:

score: 0
Accepted
time: 2790ms
memory: 1740kb

input:

1

output:

836174947389522544

result:

ok 1 number(s): "836174947389522544"

Test #3:

score: 0
Accepted
time: 1920ms
memory: 1724kb

input:

300300

output:

263358264583736303

result:

ok 1 number(s): "263358264583736303"

Test #4:

score: 0
Accepted
time: 1ms
memory: 1768kb

input:

1000000

output:

300

result:

ok 1 number(s): "300"

Test #5:

score: 0
Accepted
time: 34ms
memory: 1620kb

input:

987654

output:

323040897684351053

result:

ok 1 number(s): "323040897684351053"

Test #6:

score: 0
Accepted
time: 2707ms
memory: 1708kb

input:

2

output:

360265688540078138

result:

ok 1 number(s): "360265688540078138"

Test #7:

score: 0
Accepted
time: 1ms
memory: 1872kb

input:

999999

output:

580046907013163142

result:

ok 1 number(s): "580046907013163142"

Test #8:

score: 0
Accepted
time: 2545ms
memory: 1876kb

input:

57136

output:

886385729914317304

result:

ok 1 number(s): "886385729914317304"

Test #9:

score: 0
Accepted
time: 1321ms
memory: 1612kb

input:

511436

output:

649262956642775134

result:

ok 1 number(s): "649262956642775134"