#include <string>
#include <cmath>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <list>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
long long a, b;
int k;
cin >> a >> b;
bool num[100];
long long A[100];
A[0] = a;
a %= 1000000007;
for (int i = 0; i < 100; i++)
{
if (i > 0)
{
A[i] = A[i - 1] * A[i - 1];
A[i] %= 1000000007;
}
num[i] = false;
if (b == 0)
{
k = i;
break;
}
if (b % 2 == 1)
num[i] = true;
b /= 2;
}
long long answer = 1;
int p;
for (int i = 0; i < k; i++)
{
if (num[i])
{
answer *= A[i];
answer %= 1000000007;
}
}
cout << answer << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
1716 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |