#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
1084 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |