Submission #3902

# Submission time Handle Problem Language Result Execution time Memory
3902 2013-08-31T09:15:50 Z hyeonjae0310 Great Pow! (kriii1_G) C++
0 / 1
0 ms 1852 KB
#include <iostream>
#include <cmath>

using namespace std;

long long mm;

long long calc(long long a, long long k)
{
	a=a%mm;
	if(k==1) return pow(a,a);
	return calc(pow(a,a),k-1);
}

int main()
{
	long long a,k;
	cin>>a>>k;
	mm=a+1;
	cout<<calc(a,k)%mm;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1852 KB Output is correct
2 Correct 0 ms 1852 KB Output is correct
3 Correct 0 ms 1852 KB Output is correct
4 Correct 0 ms 1852 KB Output is correct
5 Incorrect 0 ms 1852 KB Output isn't correct
6 Halted 0 ms 0 KB -