# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
19361 |
2016-02-24T10:39:25 Z |
golala123 |
Α (kriii4_P1) |
C++ |
|
968 ms |
524288 KB |
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
long long a, x;
vector<long long> m;
vector< pair<int , int > > two;
const int MOD = 1000000007;
int main(){
cin >> a >> x;
a %= 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;
aa %= MOD;
m.push_back(aa%MOD);
temp *= 2;
i++;
}
int j = 0;
while (x != 0){
if (x%2 == 1)
two.push_back({ j, x % 2 });
x /= 2;
j++;
}
for (int i = 0; i < two.size(); i++){
if (two[i].second == 1){
ans = ans*m[two[i].first] % MOD;
ans %= MOD;
}
}
cout << ans % MOD;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Memory limit exceeded |
968 ms |
524288 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |