# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
19567 | thebarbershop | Α (kriii4_P1) | C++98 | 0 ms | 1084 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 <cstdio>
int main() {
unsigned long long int A, X;
const unsigned long long int MOD = 1000000007;
unsigned long long int Ax[65] = {0}; // Ax[i] = A^(2^i)
scanf("%I64u%I64u", &A, &X);
Ax[0] = A;
int i, j;
unsigned long long int t = X;
int bit = 0;
while(t) {
bit++;
t /= 2;
}
for(i = 1; i < bit; i++) {
Ax[i] = Ax[i-1]*Ax[i-1];
Ax[i] %= MOD;
}
unsigned long long int result = 1;
for(j = 0; j < i; j++) {
if(X&1)
result *= Ax[j];
result %= MOD;
X /= 2;
}
printf("%I64u\n", result%MOD);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |