#include<stdio.h>
unsigned long long A;
unsigned long long perA;
unsigned long long X;
unsigned long long arr[66];
short Tr[66];
int max;
int ans = 1;
void finish(int y, int dex)
{
if((y%2)) Tr[dex] = 1;
if(y/2>=1) finish(y/2, dex+1);
}
void solve(int k, int Def)
{
arr[k] = (arr[k-1]*arr[k-1]) % 1000000007;
if(Def<=X) solve(k+1,2*Def);
else {max = k; finish(X, 1);}
}
int main ()
{
scanf("%lld", &A);
scanf("%lld", &X);
perA = A % 1000000007;
arr[1] = perA;
solve(2,4);
for( int i=0 ;i<=max; i++)
if(Tr[i]) {ans= (ans*arr[i]) %1000000007;}
printf("%d", ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
1084 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |