John wants to be a scientist. A first step of becoming a scientist is to perform experiment. John has decided to experiment with eggs. He wants to compare the hardness of eggs from different species. He has decided to use a nearby large multi-storied building for this purpose. For each species he will try to find the highest floor from which he can drop the egg and it will not break. The building has (n+1) floors numbered from 0 to n. John has a book from which he knows that
Unfortunately John has a few problems.
These problems are not going to tame John’s curious mind. So he has decided to use an optimal strategy and minimize his cost in the worst case. As John is not a programmer, he has asked for your help.
Input starts with a positive integer T (T≤ 50) denoting the number of cases.
Each case contains a line with 4 integer n x y z as described in the statement. You may assume that 1 < n ≤ 1000 and 1 ≤ x, y, z ≤ 105 and x is even.
For each test case, print the case number and the minimized worst case cost.
7 4 2 998 1000 16 2 1000 1000 16 1000 1 1 4 1000 1 1 7 2 2 2 9 2 1 100 11 2 100 1
Case 1: 2000 Case 2: 4008 Case 3: 1015 Case 4: 1003 Case 5: 10 Case 6: 24 Case 7: 111
Migrated from old NTUJ.
Regional Kuala Lumpur 2010
No. | Testdata Range | Score |
---|