QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#351196#969. Discrete Logarithm is a Jokechenxinyang2006#AC ✓553ms11884kbC++141.1kb2024-03-11 18:26:202024-03-11 18:26:22

Judging History

This is the latest submission verdict.

  • [2024-03-11 18:26:22]
  • Judged
  • Verdict: AC
  • Time: 553ms
  • Memory: 11884kb
  • [2024-03-11 18:26:20]
  • Submitted

answer

#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define eb emplace_back
#define SZ(S) (int)S.size()
//#define mod 998244353
#define mod 1000000000000000031
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f
using namespace std;

template <class T>
void chkmax(T &x,T y){
	if(x < y) x = y;
}

template <class T>
void chkmin(T &x,T y){
	if(x > y) x = y;
}

inline int popcnt(int x){
	return __builtin_popcount(x);
}

inline int ctz(int x){
	return __builtin_ctz(x);
}

#define lll __int128
ll power(ll p,ll k){
	ll ans = 1;
	while(k){
		if(k % 2 == 1) ans = (lll)ans * p % mod;
		p = (lll)p * p % mod;
		k /= 2;	
	}
	return ans;
}
int n;
ll res[1000005];

int main(){
	res[1000000] = 300;
	per(i,999999,0) res[i] = power(42,res[i + 1]);
	scanf("%d",&n);
	printf("%lld\n",res[n]);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 537ms
memory: 11544kb

input:

0

output:

960002411612632915

result:

ok 1 number(s): "960002411612632915"

Test #2:

score: 0
Accepted
time: 540ms
memory: 11864kb

input:

1

output:

836174947389522544

result:

ok 1 number(s): "836174947389522544"

Test #3:

score: 0
Accepted
time: 549ms
memory: 11884kb

input:

300300

output:

263358264583736303

result:

ok 1 number(s): "263358264583736303"

Test #4:

score: 0
Accepted
time: 541ms
memory: 11600kb

input:

1000000

output:

300

result:

ok 1 number(s): "300"

Test #5:

score: 0
Accepted
time: 540ms
memory: 11868kb

input:

987654

output:

323040897684351053

result:

ok 1 number(s): "323040897684351053"

Test #6:

score: 0
Accepted
time: 543ms
memory: 11576kb

input:

2

output:

360265688540078138

result:

ok 1 number(s): "360265688540078138"

Test #7:

score: 0
Accepted
time: 553ms
memory: 11572kb

input:

999999

output:

580046907013163142

result:

ok 1 number(s): "580046907013163142"

Test #8:

score: 0
Accepted
time: 542ms
memory: 11640kb

input:

57136

output:

886385729914317304

result:

ok 1 number(s): "886385729914317304"

Test #9:

score: 0
Accepted
time: 543ms
memory: 11872kb

input:

511436

output:

649262956642775134

result:

ok 1 number(s): "649262956642775134"