OJ-Problems-Source/CodeVS/1497_冰封.c

29 lines
392 B
C
Raw Normal View History

2016-07-06 14:28:18 +08:00
/*
:
:p1497
*/
#include <stdio.h>
#define LL long long
LL exe(LL a, LL b, LL m) {
LL ret = 1;
while(b) {
if(b&1) {
ret *= a;
ret %= m;
}
b /= 2;
a *= a;
a %= m;
}
return ret;
}
int main(int argc, char** argv) {
LL a, b, m;
scanf("%lld%lld%lld", &a, &b, &m);
printf("%lld^%lld mod %lld=%lld", a, b, m, exe(a, b, m));
return 0;
}