A14279 | Gift Set
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Polycarp has $x$ of red and $y$ of blue candies. Using them, he wants to make gift sets. Each gift set contains either $a$ red candies and $b$ blue candies, or $a$ blue candies and $b$ red candies. Any candy can belong to at most one gift set.
Help Polycarp to find the largest number of gift sets he can create.
For example, if $x = 10$ , $y = 12$ , $a = 5$ , and $b = 2$ , then Polycarp can make three gift sets:
- In the first set there will be $5$ red candies and $2$ blue candies;
- In the second set there will be $5$ blue candies and $2$ red candies;
- In the third set will be $5$ blue candies and $2$ red candies.
Note that in this example there is one red candy that Polycarp does not use in any gift set.
Help Polycarp to find the largest number of gift sets he can create.
For example, if $x = 10$ , $y = 12$ , $a = 5$ , and $b = 2$ , then Polycarp can make three gift sets:
- In the first set there will be $5$ red candies and $2$ blue candies;
- In the second set there will be $5$ blue candies and $2$ red candies;
- In the third set will be $5$ blue candies and $2$ red candies.
Note that in this example there is one red candy that Polycarp does not use in any gift set.
输入格式
The first line contains an integer $t$ ( $1 \le t \le 10^4$ ). Then $t$ test cases follow.
Each test case consists of a single string containing four integers $x$ , $y$ , $a$ , and $b$ ( $1 \le x, y, a, b \le 10^9$ ).
Each test case consists of a single string containing four integers $x$ , $y$ , $a$ , and $b$ ( $1 \le x, y, a, b \le 10^9$ ).
输出格式
For each test case, output one number — the maximum number of gift sets that Polycarp can make.
输入输出样例
输入 #1
9 10 12 2 5 1 1 2 2 52 311 13 27 1000000000 1000000000 1 1 1000000000 1 1 1000000000 1 1000000000 1000000000 1 1 2 1 1 7 8 1 2 4 1 2 3
输出 #1
3 0 4 1000000000 1 1 1 5 0
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted