地址 https://leetcode-cn.com/problems/number-of-burgers-with-no-waste-of-ingredients/

目描述
圣诞活动预热开始啦,汉堡店推出了全新的汉堡套餐。为了避免浪费原料,请你帮他们制定合适的制作计划。

给你两个整数 tomatoSlices 和 cheeseSlices,分别表示番茄片和奶酪片的数目。不同汉堡的原料搭配如下:

巨无霸汉堡:4 片番茄和 1 片奶酪
小皇堡:2 片番茄和 1 片奶酪
请你以 [total_jumbo, total_small]([巨无霸汉堡总数,小皇堡总数])的格式返回恰当的制作方案,使得剩下的番茄片 tomatoSlices 和奶酪片 cheeseSlices 的数量都是 0。

如果无法使剩下的番茄片 tomatoSlices 和奶酪片 cheeseSlices 的数量为 0,就请返回 []。

示例 :

输入:tomatoSlices = , cheeseSlices =
输出:[,]
解释:制作 个巨无霸汉堡和 个小皇堡需要 * + * = 片番茄和 + = 片奶酪。不会剩下原料。
示例 : 输入:tomatoSlices = , cheeseSlices =
输出:[]
解释:只制作小皇堡和巨无霸汉堡无法用光全部原料。
示例 : 输入:tomatoSlices = , cheeseSlices =
输出:[]
解释:制作 个巨无霸汉堡会剩下 片奶酪,制作 个小皇堡会剩下 片奶酪。
示例 : 输入:tomatoSlices = , cheeseSlices =
输出:[,]
示例 : 输入:tomatoSlices = , cheeseSlices =
输出:[,]
  提示: <= tomatoSlices <= ^
<= cheeseSlices <= ^

算法1
鸡兔同笼 一个汉堡四条腿 另一个汉堡两条腿 四条腿两条腿汉堡都要吃一份奶酪
请问如何得出答案???

本题答案 要求番茄必须要在奶酪的 4 和 2的倍数之间 而且是双数
另外再假设所有材料都是以2份番茄 一份奶酪消耗 看看剩余的番茄
每剩余2份番茄就可以和之前2份番茄一份奶酪的材料 一并合成4份番茄 一份奶酪的组合
从而得出答案

 class Solution {
public: vector<int> ret;
vector<int> numOfBurgers(int tomatoSlices, int cheeseSlices) {
if (tomatoSlices > cheeseSlices * || cheeseSlices * > tomatoSlices) return ret;
if (tomatoSlices % != ) return ret; int count = cheeseSlices;
int left = tomatoSlices - cheeseSlices * ;
if (left == ) {
ret.push_back();
ret.push_back(count);
return ret;
} int leftcount = left / ;
ret.push_back(leftcount);
ret.push_back(count - leftcount);
return ret;
} };

LeetCode 5276. 不浪费原料的汉堡制作方案 Number of Burgers with No Waste of Ingredients的更多相关文章

  1. leetcode-165周赛-1276-不浪费原料的汉堡制作方案

    题目描述: 自己的提交: class Solution: def numOfBurgers(self, tomatoSlices: int, cheeseSlices: int) -> List ...

  2. 【leetcode】1276. Number of Burgers with No Waste of Ingredients

    题目如下: Given two integers tomatoSlices and cheeseSlices. The ingredients of different burgers are as ...

  3. 123457123456#0#-----com.threeapp.MakerHanBao01----儿童汉堡制作游戏

    ----com.threeapp.MakerHanBao01----儿童汉堡制作游戏

  4. 【js】Leetcode每日一题-停在原地的方案数

    [js]Leetcode每日一题-停在原地的方案数 [题目描述] 有一个长度为 arrLen 的数组,开始有一个指针在索引 0 处. 每一步操作中,你可以将指针向左或向右移动 1 步,或者停在原地(指 ...

  5. LeetCode 171. Excel表列序号(Excel Sheet Column Number) 22

    171. Excel表列序号 171. Excel Sheet Column Number 题目描述 给定一个 Excel 表格中的列名称,返回其相应的列序号. 每日一算法2019/5/25Day 2 ...

  6. leetcode解题报告(15):Third Maximum Number

    描述 Given a non-empty array of integers, return the third maximum number in this array. If it does no ...

  7. 【leetcode】Excel Sheet Column Title & Excel Sheet Column Number

    题目描述: Excel Sheet Column Title Given a positive integer, return its corresponding column title as ap ...

  8. 【leetcode】Excel Sheet Column Title & Excel Sheet Column Number (easy)

    Given a positive integer, return its corresponding column title as appear in an Excel sheet. For exa ...

  9. leetcode第18题--Letter Combinations of a Phone Number

    Problem: Given a digit string, return all possible letter combinations that the number could represe ...

随机推荐

  1. unityweb Request请求

    UnityWebRequest是新的网络请求Api,分为LLApi和HLApi,其中LLApi为低级api,所谓低级api是指只是提供最基本的api接口,然后需要通过不同的参数来确定请求方式.为此un ...

  2. 向现有URL末尾添加查询字符串参数

    向现有URL末尾添加查询字符串参数 xhr.open("get", "example.php?name1=value1&name2=value2", t ...

  3. JS设置和获取盒模型的宽和高

    JS设置和获取盒模型的宽和高 dom.style.width/height:只能取出内联样式的宽度和高度 dom.currentStyle.width/height:获取即时的计算的样式,但是只有IE ...

  4. 服务器配置:ECS+Nginx+uWSGI+Flask——各部分详细介绍

    希望在阿里云ECS上搭建一个flask框架的web应用,经典的形式便是flask+uWSGI+nginx模式 服务器:CentOS 7.3 python版本:3.8.0 先贴一张全局图,这张图很清楚的 ...

  5. 【XSY1986】【BZOJ1455】罗马游戏

    就是一模板题. 合并就直接merge. pop就是将自己的值设为一,再将自己的左右儿子合并即可. 查询直接找到堆顶,输出. 模板左偏树 代码: #include<bits/stdc++.h> ...

  6. python中“end=”用法

    python中“end=”用法:例如print(“#”,end=" \n"),默认换行,print(“#”,end=" ")则在循环中不换行

  7. CSPS模拟 62

    婚礼现场系列 T1 $gragh$ 为了方便把边的贡献下放到点,跑一个生成树作为划分依据. T2 $permutation$ 由于在本题中,构造的变换方法保证只能邻项交换 所以如果位置串字典序变小,权 ...

  8. 使用Typescript重构axios(二十八)——自定义序列化请求参数

    0. 系列文章 1.使用Typescript重构axios(一)--写在最前面 2.使用Typescript重构axios(二)--项目起手,跑通流程 3.使用Typescript重构axios(三) ...

  9. m99 然而并没有想出来标题!

    这是放假回来的第一次考试,如同往常一样,我每逢放假回来第一次考试就会废掉,这次也不例外 这次不想粘成绩,因为实在是rp没了! 之前的几次都是别人在CE等等被lemon砍分,而我被lemon多测分. 但 ...

  10. 2.4g和5g无线使用频率