Untitled
raw download clone
C
views 22
,
size 461 b
#include<stdio.h>

unsigned long long x,y,m;

unsigned long long fastpow(unsigned long long base,unsigned long long exponment)
{
     unsigned long long rst=1, pwr=base;
     unsigned long long n = exponment;
     while(n)
     {
          if(n&1) rst=(rst*pwr)%m;
          n>>=1, pwr=(pwr*pwr)%m;
     }
     return rst%m;
}

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