每日一题 1276. 不浪费原料的汉堡制作方案(中等?)

每日一题 1276. 不浪费原料的汉堡制作方案(中等?)_第1张图片
二元一次方程组

class Solution:
    def numOfBurgers(self, tomatoSlices: int, cheeseSlices: int) -> List[int]:
        t = (tomatoSlices - 2 * cheeseSlices) / 2
        return [int(t), int(cheeseSlices - t)] if t >= 0 and t <= cheeseSlices and  t == ceil(t) and t == floor(t) else []

你可能感兴趣的:(用Python刷力扣,python,算法,leetcode)