RT 写的大整数乘法打算提交A*B
import matplotlib
def getDigits(x):
return [ int(a) for a in str(x) ]
def makeInt(digits):
return sum( [ 10**(len(digits)-i-1)*digits[i] for i in range(len(digits))])
def divideAndConquerMult1( X, Y ):
return divideAndConquerMult1_helper( getDigits(X), getDigits(Y) )
def divideAndConquerMult1_helper( x, y ):
n = max( len(x), len(y) )
while len(x) < n:
x.insert(0,0)
while len(y) < n:
y.insert(0,0)
if n == 1:
return x[0]*y[0]
mid = round(n/2)
xhigh = x[:mid]
xlow = x[mid:]
yhigh = y[:mid]
ylow = y[mid:]
highhigh = divideAndConquerMult1_helper( xhigh , yhigh )
highlow = divideAndConquerMult1_helper( xhigh , ylow )
lowhigh = divideAndConquerMult1_helper( xlow , yhigh )
lowlow = divideAndConquerMult1_helper( xlow , ylow )
HH = getDigits(highhigh) + [ 0 for i in range(2*(n - mid))]
MID = getDigits(lowhigh + highlow) + [0 for i in range(n-mid)]
LL = getDigits(lowlow)
result = makeInt(HH) + makeInt(MID) + makeInt(LL)
return result
a = input()
b = input()
print(divideAndConquerMult1(a,b))