QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#218460#969. Discrete Logarithm is a JokeWRuperDAC ✓563ms19140kbC++14985b2023-10-18 12:42:172023-10-18 12:42:17

Judging History

This is the latest submission verdict.

  • [2023-10-18 12:42:17]
  • Judged
  • Verdict: AC
  • Time: 563ms
  • Memory: 19140kb
  • [2023-10-18 12:42:17]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const int mininf = 1e9 + 7;
#define int __int128
#define pb emplace_back
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
inline void write(int x){if(x<0){x=~(x-1);putchar('-');}if(x>9)write(x/10);putchar(x%10+'0');}
#define put() putchar(' ')
#define endl puts("")
const int MAX = 1000005;
const int mod = 1e18;
int ans[MAX];
int quickPower(int a,int b,int p)
{int base=a,ans=1;while(b){if(b % 2)ans*=base,ans%=p;base*=base;base%=p;b /= 2;}return ans;
}
void solve(){
    int n = 1000000;
    int now = 300;
    int mod2 = mod + 31;
    for(int i = n; i >= 0; i--){
        ans[i] = now;
        now = quickPower(42, now, mod2);
    }
    int x = read();
    write(ans[x]), endl;
}

signed main(){
    int t = 1;
    while(t--)	solve();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 549ms
memory: 19020kb

input:

0

output:

960002411612632915

result:

ok 1 number(s): "960002411612632915"

Test #2:

score: 0
Accepted
time: 559ms
memory: 19092kb

input:

1

output:

836174947389522544

result:

ok 1 number(s): "836174947389522544"

Test #3:

score: 0
Accepted
time: 562ms
memory: 18976kb

input:

300300

output:

263358264583736303

result:

ok 1 number(s): "263358264583736303"

Test #4:

score: 0
Accepted
time: 563ms
memory: 19116kb

input:

1000000

output:

300

result:

ok 1 number(s): "300"

Test #5:

score: 0
Accepted
time: 562ms
memory: 19048kb

input:

987654

output:

323040897684351053

result:

ok 1 number(s): "323040897684351053"

Test #6:

score: 0
Accepted
time: 547ms
memory: 18968kb

input:

2

output:

360265688540078138

result:

ok 1 number(s): "360265688540078138"

Test #7:

score: 0
Accepted
time: 557ms
memory: 19044kb

input:

999999

output:

580046907013163142

result:

ok 1 number(s): "580046907013163142"

Test #8:

score: 0
Accepted
time: 556ms
memory: 19140kb

input:

57136

output:

886385729914317304

result:

ok 1 number(s): "886385729914317304"

Test #9:

score: 0
Accepted
time: 561ms
memory: 18988kb

input:

511436

output:

649262956642775134

result:

ok 1 number(s): "649262956642775134"