其他分享
首页 > 其他分享> > 拼木板

拼木板

作者:互联网

'''
长木板长度 longer,短木板长度 shorter,一共有k长木板,可以拼成的木板长度区间是多少?

'''

class Solution:
    def diving_board(self,shorter,longer,k):
        if k == 0:
            return []
        ans = []
        minl = k * shorter
        ans.append(minl)
        if shorter == longer:
            return ans
        for i in range(k):
            ans.append(minl + longer - shorter)
            minl = minl + longer - shorter
        return ans

longer = 5
shorter = 3
k = 4
r = Solution().diving_board(shorter,longer,k)
print(r)

标签:return,木板,shorter,ans,minl,longer
来源: https://www.cnblogs.com/ray-mmss/p/16626132.html