Submission #4040

#TimeUsernameProblemLanguageResultExecution timeMemory
4040pmpmpGreat Pow! (kriii1_G)C++98
0 / 1
0 ms1088 KiB
#include <stdio.h> long long a, bb; long long dfs(int k) { long long aa; if(k==1){ return a; } aa=dfs(k/2)%(a+1); if(k%2==1){return (( (a*aa)%(a+1) )*aa)%(a+1);} else{ return (aa*aa)%(a+1); } } int main () { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); int b, c; int i, j, k, t; scanf("%lld %d", &a, &k); bb=dfs(k+1); printf("%lld", bb%(a+1)); }
#Verdict Execution timeMemoryGrader output
Fetching results...