Submission #19567

# Submission time Handle Problem Language Result Execution time Memory
19567 2016-02-24T19:39:05 Z thebarbershop Α (kriii4_P1) C++
0 / 100
0 ms 1084 KB
#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
1 Incorrect 0 ms 1084 KB Output isn't correct
2 Halted 0 ms 0 KB -