답안 #19560

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
19560 2016-02-24T18:27:03 Z inspire12 Α (kriii4_P1) C++
100 / 100
0 ms 1208 KB
#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 % 1000000007) *(temp % 1000000007 ))% 1000000007;
		temp = p.first;
		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)) % 1000000007, m-= a;
		v.pop_back();
	} printf("%lld", res);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1208 KB Output is correct
2 Correct 0 ms 1208 KB Output is correct
3 Correct 0 ms 1208 KB Output is correct
4 Correct 0 ms 1208 KB Output is correct
5 Correct 0 ms 1208 KB Output is correct
6 Correct 0 ms 1208 KB Output is correct
7 Correct 0 ms 1208 KB Output is correct
8 Correct 0 ms 1208 KB Output is correct
9 Correct 0 ms 1208 KB Output is correct
10 Correct 0 ms 1208 KB Output is correct
11 Correct 0 ms 1208 KB Output is correct
12 Correct 0 ms 1208 KB Output is correct
13 Correct 0 ms 1208 KB Output is correct
14 Correct 0 ms 1208 KB Output is correct
15 Correct 0 ms 1208 KB Output is correct
16 Correct 0 ms 1208 KB Output is correct
17 Correct 0 ms 1208 KB Output is correct
18 Correct 0 ms 1208 KB Output is correct
19 Correct 0 ms 1208 KB Output is correct
20 Correct 0 ms 1208 KB Output is correct