Submission #19348

#TimeUsernameProblemLanguageResultExecution timeMemory
19348golala123Α (kriii4_P1)C++98
0 / 100
0 ms1720 KiB
#include <iostream> #include <stdio.h> #include <vector> using namespace std; long long a, x; vector<long long> m; vector<int> two; const int MOD = 1000000007; int main(){ cin >> a >> x; a %= MOD; x %= MOD; int temp = 1; int i = 0; long long ans = 1; m.push_back(a); while (temp <= x){ long long aa = 1; aa = m[i]%MOD * m[i]%MOD; m.push_back(aa%MOD); temp *= 2; i++; } while (x != 0){ two.push_back(x%2); x /= 2; } for (int i = 0; i < two.size(); i++){ if (two[i] == 1){ ans = ans*m[i] % MOD; ans %= MOD; } } cout << ans % MOD; }
#Verdict Execution timeMemoryGrader output
Fetching results...