# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
19496 | sung927 | Α (kriii4_P1) | C++98 | 0 ms | 1280 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<stdio.h>
#include<math.h>
long long A;
long long perA;
long long X;
long long arr[65];
bool Tr[65];
int max;
unsigned long long 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)
{
arr[k] = (int)((unsigned long long)(arr[k-1]*arr[k-1]) % 1000000007);
if(pow(2,k)<=X) solve(k+1);
else {max = k; finish(X, 1);}
}
int main ()
{
scanf("%lld\n%lld", &A, &X);
perA = A % 1000000007;
arr[1] = perA;
solve(2);
for(int i=1; i<=max+1; i++) {if(Tr[i]) ans*= arr[i]; if(ans>1000000007) ans%=1000000007;}
printf("%lld", ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |