#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;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
- |