QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#217957 | #969. Discrete Logarithm is a Joke | zlt | AC ✓ | 531ms | 3716kb | C++14 | 810b | 2023-10-17 16:34:56 | 2023-10-17 16:34:56 |
Judging History
answer
#include <bits/stdc++.h>
#define pb emplace_back
#define fst first
#define scd second
#define mkp make_pair
#define mems(a, x) memset((a), (x), sizeof(a))
using namespace std;
typedef long long ll;
typedef __int128 lll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;
typedef pair<ll, ll> pii;
const ll G = 42, mod = 1000000000000000031LL;
inline ll qpow(ll b, ll p) {
ll res = 1;
while (p) {
if (p & 1) {
res = (lll)res * b % mod;
}
b = (lll)b * b % mod;
p >>= 1;
}
return res;
}
void solve() {
ll n;
scanf("%lld", &n);
ll res = 300;
for (int i = 999999; i >= n; --i) {
res = qpow(42, res);
}
printf("%lld\n", res);
}
int main() {
int T = 1;
// scanf("%d", &T);
while (T--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 524ms
memory: 3644kb
input:
0
output:
960002411612632915
result:
ok 1 number(s): "960002411612632915"
Test #2:
score: 0
Accepted
time: 523ms
memory: 3672kb
input:
1
output:
836174947389522544
result:
ok 1 number(s): "836174947389522544"
Test #3:
score: 0
Accepted
time: 374ms
memory: 3672kb
input:
300300
output:
263358264583736303
result:
ok 1 number(s): "263358264583736303"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
1000000
output:
300
result:
ok 1 number(s): "300"
Test #5:
score: 0
Accepted
time: 7ms
memory: 3660kb
input:
987654
output:
323040897684351053
result:
ok 1 number(s): "323040897684351053"
Test #6:
score: 0
Accepted
time: 531ms
memory: 3676kb
input:
2
output:
360265688540078138
result:
ok 1 number(s): "360265688540078138"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
999999
output:
580046907013163142
result:
ok 1 number(s): "580046907013163142"
Test #8:
score: 0
Accepted
time: 498ms
memory: 3716kb
input:
57136
output:
886385729914317304
result:
ok 1 number(s): "886385729914317304"
Test #9:
score: 0
Accepted
time: 256ms
memory: 3660kb
input:
511436
output:
649262956642775134
result:
ok 1 number(s): "649262956642775134"