Submission #19449

# Submission time Handle Problem Language Result Execution time Memory
19449 2016-02-24T12:41:36 Z codingman Α (kriii4_P1) C++14
0 / 100
1000 ms 524288 KB
#include <fstream>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <stack>
#include <string>
#include <regex>
#include <map>
#include <numeric>
using namespace std;
vector<string> s;
//string c;

long long A, X;
vector<int> Avector;
/*
첫 번째 줄에는 정수 A(1?≤?A?≤?10^18)이 주어진다.

두 번째 줄에는 정수 X(1?≤?X?≤?10^18)가 주어진다.
*/
int main()
{ 
	cin >> A >> X;
	long long mod = 1000000007;
	//Avector.push_back(1);

	long long temp = 1;
	Avector.push_back(A);
	//long long prevValue = A;
	int cnt = 1;
	while(1)
	{
		//if(temp >= X)
		//{
		//	break;
		//} 
		auto t = (Avector.back() % mod)* (Avector.back() % mod) % mod;
		if(cnt > X)
			break;
		else 
			Avector.push_back(t); 
		cnt <<= 1;
	}

	
	long long tX = X;
	vector<int> binary;
	while(tX)
	{
		//printf("%d", tX % 2);
		binary.push_back(tX % 2);
		tX /= 2;

	}

	long long result = 1;
	for(int i=0; i<binary.size(); i++)
	{
		if(binary[i])
		{
			result = (result  % mod) * (Avector[i] % mod) % mod; 
		}
	}


	cout << result;


	return 0;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 524288 KB Program timed out
2 Halted 0 ms 0 KB -