Untitled
raw download clone
TEXT
views 17
,
size 411 b
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

long long fpw(long long x,long long y,long long m)
{
    if(y==0)
        return 1%m;
    long long res = fpw(x,y/2,m);
    res = res*res%m;
    if(y%2==1)
        res = res * x % m;
    return res%m;
}
int main()
{
    unsigned long long N,M,K;
    scanf("%lld%lld%lld",&N,&M,&K);
    printf("%lld\n",fpw(N,M,K)%K);
    return 0;

}
close fullscreen
Login or Register to edit or fork this paste. It's free.