#abc338c. C - Leftover Recipes
C - Leftover Recipes
Score: points
问题描述
你的冰箱里有 种食材。我们称它们为食材 , , 食材 。你拥有 克的第 种食材。
你可以制作两种类型的菜肴。制作一份 A 类菜肴,你需要每种食材 的 克。制作一份 B 类菜肴,你需要每种食材 的 克。你只能制作整数份的每种类型菜肴。
仅使用冰箱中的食材,你能做出的最大总份数是多少?
约束条件
- 存在一个 使得 。
- 存在一个 使得 。
- 所有输入值都是整数。
输入
输入格式如下:
输出
假设你最多可以制作 份菜肴,请输出整数 。
示例输入 1
2
800 300
100 100
200 10
示例输出 1
5
这个冰箱有 克成分 和 克成分 。
你可以用 克成分 和 克成分 制作一份 A 菜,以及用 克成分 和 克成分 制作一份 B 菜。
制作两份 A 菜和三份 B 菜,你需要 克成分 ,以及 克成分 ,这些都没有超过冰箱里的存量。这样,你可以总共制作五份菜肴,但是没有办法制作六份,所以答案是 。
示例输入 2
2
800 300
100 0
0 10
示例输出 2
38
你可以用 克成分 制作 份 A 菜,以及用 克成分 制作 份 B 菜,总共 份。
示例输入 3
2
800 300
801 300
800 301
示例输出 3
0
你不能制作任何菜肴。
示例输入 4
10
1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000
0 1 2 3 4 5 6 7 8 9
9 8 7 6 5 4 3 2 1 0
示例输出 4
222222
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Your refrigerator has kinds of ingredients. Let us call them ingredient , , ingredient . You have grams of ingredient .
You can make two types of dishes. To make one serving of dish A, you need grams of each ingredient . To make one serving of dish B, you need grams of each ingredient . You can only make an integer number of servings of each type of dish.
Using only the ingredients in the refrigerator, what is the maximum total number of servings of dishes you can make?
Constraints
- There is an such that .
- There is an such that .
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Assuming that you can make a maximum total of servings of dishes, print the integer .
Sample Input 1
2
800 300
100 100
200 10
Sample Output 1
5
This refrigerator has grams of ingredient and grams of ingredient .
You can make one serving of dish A with grams of ingredient and grams of ingredient , and one serving of dish B with grams of ingredient and grams of ingredient .
To make two servings of dish A and three servings of dish B, you need grams of ingredient , and grams of ingredient , neither of which exceeds the amount available in the refrigerator. In this way, you can make a total of five servings of dishes, but there is no way to make six, so the answer is .
Sample Input 2
2
800 300
100 0
0 10
Sample Output 2
38
You can make servings of dish A with grams of ingredient , and servings of dish B with grams of ingredient , for a total of servings.
Sample Input 3
2
800 300
801 300
800 301
Sample Output 3
0
You cannot make any dishes.
Sample Input 4
10
1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000
0 1 2 3 4 5 6 7 8 9
9 8 7 6 5 4 3 2 1 0
Sample Output 4
222222
update @ 2024/3/10 01:29:07
相关
在下列比赛中: