The Fastest Method
Easy Accuracy: 11.49% Submissions: 506 Points: 2

Ishaan lives in a multi-story building. Everyday he has to get to the ground floor from the Nth floor. He has three options to come down, the lift, the stairs or the escalator. He has different speeds for the lift, the stairs and the escalator which are V1 m/s, V2 m/s and V3 m/s respectively. 
Assuming each floor has a height of 1m and the stairs and the escalator are inclined at an angle of 45 degrees.
Find out which is the fastest way for Ishaan to reach the ground floor.
If any of the methods consume same time, give preference to lift, then stairs and then escalator.

Input : 
First line of input contains a single integer T denoting the number of test cases.
The only line of each test case contains 4 space-separated integers N, V1, V2 and V3.

Output : 
For each test case, print "1" if lift is fastest, "2" if stairs are fastest and "3" if escalator is fastest in a new line (without quotes "").

Constraints : 
1 <= T <= 200
1 <= N <= 1000
1 <= V1,V2,V3 <= 1000

Example : 
Input : 
3
5 1 2 3
5 3 2 1
6 2 3 1
Output : 
3
1
2

Explanation : 
The distance for stairs and escalator is sqrt(2)*N because they are inclined at a 45 degree angle.

Case 1 : 
Time taken by lift : N/V1 = 5
Time taken by stairs : (N*sqrt(2))/V2 = 3.535
Time taken by escalator : (N*sqrt(2))/V3 = 2.356

Case 2 : 
Time taken by lift : N/V1 = 1.666
Time taken by stairs : (N*sqrt(2))/V2 = 3.535
Time taken by escalator : (N*sqrt(2))/V3 = 7.07

Case 3 : 
Time taken by lift : N/V1 = 3
Time taken by stairs : (N*sqrt(2))/V2 = 2.828
Time taken by escalator : (N*sqrt(2))/V3 = 8.484

 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.