답안 #19595

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
19595 2016-02-24T23:50:11 Z panda959595 Α (kriii4_P1) C++
100 / 100
0 ms 1716 KB
#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 %= 1000000007;
	A[0] = a;
	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 Correct 0 ms 1716 KB Output is correct
2 Correct 0 ms 1716 KB Output is correct
3 Correct 0 ms 1716 KB Output is correct
4 Correct 0 ms 1716 KB Output is correct
5 Correct 0 ms 1716 KB Output is correct
6 Correct 0 ms 1716 KB Output is correct
7 Correct 0 ms 1716 KB Output is correct
8 Correct 0 ms 1716 KB Output is correct
9 Correct 0 ms 1716 KB Output is correct
10 Correct 0 ms 1716 KB Output is correct
11 Correct 0 ms 1716 KB Output is correct
12 Correct 0 ms 1716 KB Output is correct
13 Correct 0 ms 1716 KB Output is correct
14 Correct 0 ms 1716 KB Output is correct
15 Correct 0 ms 1716 KB Output is correct
16 Correct 0 ms 1716 KB Output is correct
17 Correct 0 ms 1716 KB Output is correct
18 Correct 0 ms 1716 KB Output is correct
19 Correct 0 ms 1716 KB Output is correct
20 Correct 0 ms 1716 KB Output is correct