CF2113A.Shashliks

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Shashliks

You are the owner of a popular shashlik restaurant, and your grill is the heart of your kitchen. However, the grill has a peculiarity: after cooking each shashlik, its temperature drops.

You need to cook as many portions of shashlik as possible, and you have an unlimited number of portions of two types available for cooking:

  • The first type requires a temperature of at least aa degrees at the start of cooking, and after cooking, the grill's temperature decreases by xx degrees.
  • The second type requires a temperature of at least bb degrees at the start of cooking, and after cooking, the grill's temperature decreases by yy degrees.

Initially, the grill's temperature is kk degrees. Determine the maximum total number of portions of shashlik that can be cooked.

Note that the grill's temperature can be negative.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041 \le t \le 10^4). The description of the test cases follows.

The only line of each test case contains five integers kk, aa, bb, xx, and yy (1k,a,b,x,y1091 \le k, a, b, x, y \le 10^9) — the initial temperature of the grill, the required temperature for cooking the first and second types of shashlik, respectively, as well as the temperature drop after cooking the first and second types of shashlik, respectively.

Output

For each test case, output a single integer — the maximum number of portions of shashlik that you can cook.

Note

In the first test case, it is advantageous to cook 77 portions of the second type of shashlik; after that, the grill's temperature will be 33 degrees, and we can cook one more portion of the first type of shashlik.

In the second test case, we cannot cook either type of shashlik because the grill is too cold.

In the fourth test case, it is advantageous to cook 88 portions of the first type of shashlik; after that, it will be possible to cook another 22 portions of the second type of shashlik.

Samples

5
10 3 4 2 1
1 10 10 1 1
100 17 5 2 3
28 14 5 2 4
277 5 14 1 3
8
0
46
10
273

在线编程 IDE

建议全屏模式获得最佳体验