#include <cstdio>
#include <vector>
using namespace std;
vector<pair<long long, long long> > v;
unsigned long long res = 1;
int main() {
long long n;
long long m;
long long i;
unsigned long long temp;
pair<long long, long long> p;
long long num = 0;
scanf("%lld", &n);
scanf("%lld", &m);
p.first = n;
p.second = 1;
v.push_back(p);
temp = n;
for (i = 2; i <= m; i *= 2) {
p.first = (temp * temp) % 1000000007;
temp = ( temp * temp )% 1000000007;
p.second = i;
v.push_back(p);
} long long a;
while(!v.empty() && m>0){
a = v[v.size() - 1].second;
if(m- a>=0) res = ((res % 1000000007) * (v[v.size()-1].first % 1000000007)), m-= a;
v.pop_back();
} printf("%lld", res % 1000000007);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
1208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |