Bob built an empire with five cities \((C_1, C_2, C_3, C_4, C_5)\). The only mode of transport in this empire is the train.
- One can travel from \(C_1\)to \(C_2\) in one minute. This train can occupy at most $$A$$ people.
- One can travel from \(C_2\)to \(C_3\) in one minute. This train can occupy at most $$B$$ people.
- One can travel from \(C_3 \)to \(C_4\) in one minute. This train can occupy at most $$C$$ people.
- One can travel from \(C_4\)to \(C_5\) in one minute. This train can occupy at most $$D$$ people.
For each of them, a train leaves the city at each integer time \((0, 1, 2, ...)\).
There is a group of $$N$$ people at $$C_1$$, and they all want to go to $$C_5$$.
At least how long does it take for all of them to reach there? You can ignore the time needed to transfer.
Input format
- The first line contains an integer $$T$$ denoting the number of test cases.
- The first line of each test case contains a single integer $$N$$.
- The second line of each test case contains four space-separated integers \(A,B,C\), and \(D\) respectively.
Output format
For each test case, print the minimum time required for all of the people to reach $$C_5$$ (in minutes) in a new line.
Constraints
For the first test case, it will take in total $$5$$ minutes to reach $$C_5$$.
In the first three minutes, $$2$$ people will non-stop travel to $$C_4$$ from $$C_1$$. Since only $$1$$ person can travel at a time from $$C_4$$ to $$C_5$$. Thus, total travel time is $$5$$ minutes.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor