LeetCode?启动!!!
题目链接:1276. 不浪费原料的汉堡制作方案
func numOfBurgers(tomatoSlices int, cheeseSlices int) []int {
if tomatoSlices%2 != 0 || tomatoSlices < cheeseSlices*2 || cheeseSlices*4 < tomatoSlices {
return nil
}
return []int{tomatoSlices/2-cheeseSlices, cheeseSlices*2-tomatoSlices/2}
}
你敢信吗,这道题居然是解二元一次方程,谢谢,我都傻眼了
设巨无霸 x 个,小皇堡 y 个
4x + 2y = tomatoSlices
x + y = cheeseSlices
怎么 LeetCode 最近老出数学题?