# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
154696 | junodeveloper | Great Pow! (kriii1_G) | C++14 | 2 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int modpow(int a, long long n, int mod) {
int r = 1, b = a;
while(n > 0) {
if(n & 1) r = 1ll * r * b % mod;
b = 1ll * b * b % mod;
n >>= 1;
}
return r;
}
int Pow(int a,int n) {
if(n==0) return a;
int h=Pow(a,n/2);
h=modpow(h,h,a+1);
if(n&1) h=modpow(a,h,a+1);
return h;
}
int a,k;
int main() {
scanf("%d%d",&a,&k);
printf("%lld",Pow(a,k+1));
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |