Submission #4040

# Submission time Handle Problem Language Result Execution time Memory
4040 2013-08-31T15:04:41 Z pmpmp Great Pow! (kriii1_G) C++
0 / 1
0 ms 1088 KB


#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 time Memory Grader output
1 Correct 0 ms 1088 KB Output is correct
2 Incorrect 0 ms 1088 KB Output isn't correct
3 Halted 0 ms 0 KB -