拼木板

'''
长木板长度 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)
posted @ 2022-08-25 23:12  Ray_chen  阅读(19)  评论(0编辑  收藏  举报