Untitled
raw download clone
TEXT
views 59
,
size 564 b
#include <stdio.h>

long long int x,y,m;
long long int ans,res;

long long int fpw(long long int x, long long int y, long long int m){
    if (y==0) return 1% m;
    else{
        res = fpw(x,y/2,m);
        res = res*res%m;

      //  if (y % 2 == 0){
      //  res = fpw(x,y/2,m);
      //  res = res*res%m;
      //}
        if (y % 2 == 1){
     //   res = fpw(x,y/2,m);
        res = res*x%m;
        }
    }
    return res;
}

int main(void){
    scanf("%lld%lld%lld",&x,&y,&m);
    printf("%lld\n", fpw(x,y,m));
    return 0 ;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.