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

long long int x_to_the_y( long long int x , long long int y , long long int m )
{
    if( y==0 ) return 1%m ;

    long long int res = x_to_the_y( x , y/2 , m ) ;
    res = (res * res) % m ;
    if( y%2 == 1 ) res = (x * res) % m ;
    return res ;
}

int main()
{
    long long int x , y , m ;
    scanf("%lld %lld %lld" , &x, &y, &m) ;

    long long int ans = x_to_the_y( x , y , m ) ;
    printf("%lld\n",ans) ;

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