# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
154696 | 2019-09-23T14:37:58 Z | junodeveloper | Great Pow! (kriii1_G) | C++14 | 2 ms | 384 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Incorrect | 2 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |