- 小胖的水果
- 2018-09-09 20:49:43 @
import numpy as np
import sys
def lby(x,y):
if x<0 or y<0:
return 0
else:
return f[x][y]
def ans():
for i in range(0, len(a)):
for j in range(0, len(b)):
if a[i] == b[j]:
f[i][j] = lby(i - 1, j - 1) + 1
else:
f[i][j] = max(lby(i - 1, j), lby(i, j - 1))
return(len(a) + len(b) - f[len(a) - 1][len(b) - 1])
for line in sys.stdin:
a,b=map(str,line.split())
f = np.array([[0] * len(b)] * len(a))
print(ans())
自己测试没问题,提交上去就会Runtime error
0 条评论
目前还没有评论...