/*
Copyright 2011 Marek "p2004a" Rusinowski
Exponentiation by squaring (iterative)
*/
#include <cstdio>
int pow ( int a, int b, int c) {
int d = a, res = 1 ;
while ( b) {
res = ( res * ( b & 1 ? d : 1 ) ) % c;
b >>= 1 ;
d = ( d * d) % c;
}
return res;
}
int main( ) {
int a, b, c;
scanf ( "%d %d %d" , & a, & b, & c) ;
printf ( "%d\n " , pow ( a, b, c) ) ;
return 0 ;
}
LyoKICBDb3B5cmlnaHQgMjAxMSBNYXJlayAicDIwMDRhIiBSdXNpbm93c2tpCiAgRXhwb25lbnRpYXRpb24gYnkgc3F1YXJpbmcgKGl0ZXJhdGl2ZSkKKi8KI2luY2x1ZGUgPGNzdGRpbz4KCmludCBwb3cgKGludCBhLCBpbnQgYiwgaW50IGMpIHsKICBpbnQgZCA9IGEsIHJlcyA9IDE7CiAgd2hpbGUgKGIpIHsKICAgIHJlcyA9IChyZXMgKiAoYiAmIDEgPyBkIDogMSkpICUgYzsKICAgIGIgPj49IDE7CiAgICBkID0gKGQgKiBkKSAlIGM7CiAgfQogIHJldHVybiByZXM7Cn0KCmludCBtYWluKCkgewogIGludCBhLCBiLCBjOwogIHNjYW5mKCIlZCAlZCAlZCIsICZhLCAmYiwgJmMpOwogIHByaW50ZigiJWRcbiIsIHBvdyhhLCBiLCBjKSk7CiAgcmV0dXJuIDA7Cn0K
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
stdout