Submission #19594

# Submission time Handle Problem Language Result Execution time Memory
19594 2016-02-24T23:48:58 Z panda959595 Α (kriii4_P1) C++
0 / 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[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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1716 KB Output isn't correct
2 Halted 0 ms 0 KB -