308560: CF1538G. Gift Set
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Gift Set
题意翻译
Polycarp有$x个$红糖和$y$个蓝糖,现在他想用这些糖果做一些礼品盒(gift set),但规定每个礼品盒里必须有$a$个红糖、$b$个蓝糖或$b$个红糖、$a$个蓝糖。现在求他最多能做成多少个礼品盒。 #### 输入格式 第一行是一个数字$t$,表示有$t$组数据。 接下来$t$行每行4个数,表示$x$,$y$,$a$,$b$。 #### 输出格式 一共$t$行,第$i$行表示输入中第$i+1$行的答案题目描述
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.输入输出格式
输入格式
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 $ ).
输出格式
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