답안 #19608

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
19608 2016-02-25T01:16:50 Z noeffserv Α (kriii4_P1) C++
100 / 100
0 ms 1716 KB
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <iostream>

#define ENP     printf("**Entry Point**\n")
#define A       first
#define B       second
#define MP      make_pair

using namespace std;

typedef long long                       ll;
typedef vector  <double>              vec_d;
typedef vector  <vec_d>                   vvec_d;
typedef vector  <int>                 vec_i;
typedef vector  <vec_i>                   vvec_i;
typedef pair    <int, int>                pair_i;
typedef pair    < pair_i, pair_i >        pp_i;

const int INF = 0x60000000;
const int MINF = -1000000000;
const ll mod = 1000000007;
const int cons = 50000001;

ll table[64];

int main()
{
	ll a, x;
	cin >> a >> x;

	a %= mod;

	table[1] = a;

	ll ans = 1;

	for (int i = 2; i < 64; i++)
	{
		table[i] = (table[i - 1] * table[i - 1]) % mod;
	}

	for (int i = 63; i >= 1; i--)
	{
		ll t = (1LL << (i - 1));
		if (x >= t)
		{
			x -= t;
			ans = (ans * table[i]) % mod;
		}
	}

	cout << ans << 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