QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#466645 | #969. Discrete Logarithm is a Joke | masterhuang | AC ✓ | 530ms | 11616kb | C++20 | 476b | 2024-07-07 23:41:35 | 2024-07-07 23:41:36 |
Judging History
answer
#include<bits/stdc++.h>
#define LL long long
#define bll __uint128_t
#define fr(x) freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);
using namespace std;
const LL N=1e6+5,M=N-5,mod=1000000000000000031;
LL n,a[N];
inline LL ksm(LL x,LL p){LL s=1;for(;p;(p&1)&&(s=(bll)s*x%mod),x=(bll)x*x%mod,p>>=1);return s;}
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin>>n;
a[M]=300;for(int i=M-1;i>=n;i--) a[i]=ksm(42,a[i+1]);
return cout<<a[n],0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 527ms
memory: 11420kb
input:
0
output:
960002411612632915
result:
ok 1 number(s): "960002411612632915"
Test #2:
score: 0
Accepted
time: 526ms
memory: 11612kb
input:
1
output:
836174947389522544
result:
ok 1 number(s): "836174947389522544"
Test #3:
score: 0
Accepted
time: 371ms
memory: 10324kb
input:
300300
output:
263358264583736303
result:
ok 1 number(s): "263358264583736303"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
1000000
output:
300
result:
ok 1 number(s): "300"
Test #5:
score: 0
Accepted
time: 7ms
memory: 3628kb
input:
987654
output:
323040897684351053
result:
ok 1 number(s): "323040897684351053"
Test #6:
score: 0
Accepted
time: 530ms
memory: 11616kb
input:
2
output:
360265688540078138
result:
ok 1 number(s): "360265688540078138"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
999999
output:
580046907013163142
result:
ok 1 number(s): "580046907013163142"
Test #8:
score: 0
Accepted
time: 499ms
memory: 10964kb
input:
57136
output:
886385729914317304
result:
ok 1 number(s): "886385729914317304"
Test #9:
score: 0
Accepted
time: 259ms
memory: 7980kb
input:
511436
output:
649262956642775134
result:
ok 1 number(s): "649262956642775134"