python 玻璃球在哪摔碎

d={}
def T(level, ball):
    if d.get((level, ball)):
        return d[(level, ball)]
    if ball is 1:
        return level
    elif level is 1:
        return 1
    elif level is 0:
        return 0
    res_list=[]
    for l in range(1,level+1):
        res_list.append(max(T(l-1, ball-1), T(level-l, ball)) + 1 )
    res = min(res_list)
    d[(level, ball)] = res
    return res
print(T(39,2))

python 玻璃球在哪摔碎_第1张图片

 

转载于:https://www.cnblogs.com/KakagouLT/p/9595487.html

你可能感兴趣的:(python 玻璃球在哪摔碎)