Submission #3487

#TimeUsernameProblemLanguageResultExecution timeMemory
3487Apple_CplusGreat Pow! (kriii1_G)C++98
1 / 1
0 ms1088 KiB
#include <cstdio> int main(void) { int n, K; scanf("%d %d", &n, &K); if(K == 0) printf("%d\n", n); else { long long cur = 1; for(int i=30;i>=0;i--) { cur = cur * cur % (n + 1); if(n & (1LL << i)) cur = cur * n % (n + 1); } printf("%d\n", cur); } }
#Verdict Execution timeMemoryGrader output
Fetching results...