P17626 [CodeChef] MARARUN
普及-
题目描述

Read problems statements in [Mandarin Chinese], [Russian], [Vietnamese] and [Bengali] as well.

Chefland is holding a virtual marathon for the categories 10 km, 21 km and 42 km having prizes A, B, C (A < B < C) respectively to promote physical fitness. In order to claim the prize in a particular category the person must cover the total distance for that category within D days. Also a single person cannot apply in multiple categories.

Given the maximum distance d km that Chef can cover in a single day, find the maximum prize that Chef can win at the end of D days. If Chef can't win any prize, print 0.

------ Input Format ------

  • The first line contains an integer T, the number of test cases. Then the test cases follow.
  • Each test case contains a single line of input, five integers D, d, A, B, C.

------ Output Format ------

For each test case, output in a single line the answer to the problem.

------ Constraints ------

$1 ≤ T ≤ 50$
$1 ≤ D ≤ 10$
$1 ≤ d ≤ 5$
$1 ≤ A < B < C ≤ 10^{5}$

----- Sample Input 1 ------
3

1 1 1 2 3

10 1 1 2 3

10 3 1 2 3
----- Sample Output 1 ------
0

1

2
----- explanation 1 ------
Test Case $1$: The maximum distance covered by Chef is $1 \cdot 1 = 1$ km which is less than any of the available distance categories. Hence Chef won't be able to claim a prize in any of the categories.

Test Case $2$: The maximum distance covered by Chef is $10 \cdot 1 = 10$ km which is equal to distance of the first category. Hence Chef can claim the maximum prize of $1$ units.

Test Case $3$: The maximum distance covered by Chef is $10 \cdot 3 = 30$ km which is more than the distance of the second category but less than that of the third category. Hence Chef can claim the maximum prize of $2$ units.

输入格式

见题面

输出格式

见题面

样例输入
3 1 1 1 2 3 10 1 1 2 3 10 3 1 2 3
样例输出
0 1 2