Ajay wants to purchase a new car for his birthday

Ajay wants to purchase a new car for his birthday. He finally finds himself with two options:

Car 1: Uses diesel fuel and has a fuel efficiency of x1 km/l

Car 2: Uses petrol and has a fuel efficiency of x2 km/l.

Additionally, Ajay is aware that the price of diesel is currently y1 rupees per litre and the price of petrol is currently y2 rupees per litre.

Which vehicle will reduce Ajay costs, assuming that both are equally priced and that fuel prices remain the same?

Ajay wants to purchase

Explanation:

Test Case: Driving Car 1 costs 1 rupee per kilometre, while driving Car 2 costs the same. The output is 0 since both vehicles have the same fuel economy.

Input Format:

The number of test cases, represented by the single integer T on the first line of input, is included. The T test case description is provided after. There are 4 space-separated numbers (x1, x2, y1, y2) in test case, which is composed of a single line.

Sample Input:

3
10 5 3 20
7 2 7 2
1 5 3 2

Constraints:

1 ≤ T ≤ 1000

1 ≤ x1, x2, y1, y2 ≤ 50

Output Format:

Print -1 if it is preferable to select Car 1.

Print 0 if the costs for both vehicles will be the same.

Print out option 1 if Car 2 is the superior option.

Sample Output: -1 0 1

Solution

T = int(input())
for i in range(T):
    x = list(map(int, input().split()))
    if x[2]/x[0] < x[3]/x[1]:
        print(-1)
        #sauravhathi
    elif x[2]/x[0] == x[3]/x[1]:
        print(0)
    else:
        print(1)

Happy Learning – If you require any further information, feel free to contact me.

Share your love
Saurav Hathi

Saurav Hathi

I'm currently studying Bachelor of Computer Science at Lovely Professional University in Punjab.

📌 Nodejs and Android 😎
📌 Java

Articles: 444

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *