Untitled
raw download clone
TEXT
views 16
,
size 374 b
#include<stdio.h>
long long power(long long x, long long y, long long m)
{
    if(y==0) return 1%m;
    if(y==1) return x%m;
    int res = power(x, y/2, m);
    if(y%2==0) return (res*res)%m;
    else return x*(res*res)%m;
}
int main(void){
    long long x, y, m;
    scanf("%lld %lld %lld", &x, &y, &m);
    printf("%lld\n", power(x, y, m));
    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.