首页 > 其他分享 >拼木板

拼木板

时间:2022-08-25 23:23:51浏览次数:46  
标签:return 木板 shorter ans minl longer

'''
长木板长度 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
From: https://www.cnblogs.com/ray-mmss/p/16626132.html

相关文章