AcWing 90. 【python】64位整数乘法
原题链接
简单
作者:
tt2767
,
2019-12-02 22:27:34
,
所有人可见
,
阅读 721
import re
import sys
def read(raw):
sbuffer = list()
for s in raw:
if re.match('\s', s) is None:
sbuffer.append(s)
elif len(sbuffer) > 0:
yield ''.join(sbuffer)
sbuffer = list()
yield ''.join(sbuffer)
def mul(a, b, p):
res = 0
while b != 0:
if b & 1 == 1:
res = res + a % p
a = a + a % p
b = b >> 1
return res % p
pin = read(sys.stdin.read())
a = int(pin.next())
b = int(pin.next())
p = int(pin.next())
print mul(a, b, p)