Submission #19565

#TimeUsernameProblemLanguageResultExecution timeMemory
19565thebarbershopΑ (kriii4_P1)C++98
0 / 100
0 ms1084 KiB
#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]%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); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...