看大家都是用c++的竞赛党啊,退役狗决定用python 和 java 来刷一遍
import re
import sys
def read():
sbuffer = list()
for s in sys.stdin.read():
if re.match('\s', s) is not None:
if len(sbuffer) != 0:
yield ''.join(sbuffer)
sbuffer = list()
else:
sbuffer.append(s)
yield ''.join(sbuffer)
def power(a, b, p):
ans = 1 % p
while b != 0:
if( b&1 ) == 1:
ans = (ans * a) % p
a = (a * a) % p
b = (b >> 1)
return ans
a = int(read().next())
b = int(read().next())
p = int(read().next())
print power(a, b, p)