# PROBLEM LINK:

**Setter:** inov_adm

**Testers:** utkarsh_25dec, iceknight1093

# DIFFICULTY:

831

# PREREQUISITES:

None

# PROBLEM:

Given cost and mileage of petrol and diesel, find which is the cheaper option to travel N kms.

# EXPLANATION:

The cost incurred if you use the petrol car, is the cost of petrol times the amount of petrol used. Which is x * (n/a). Similarly, the cost of using the diesel car is the cost of diesel times the amount of diesel used. Which is y * (n/b). We just find which one of these is smaller, and output that. If they are equal, output “Any”.

# TIME COMPLEXITY:

Time complexity is O(1).

# SOLUTION:

## Editorialist's Solution

```
#include <iostream>
#include <cmath>
using namespace std;
int T,n,x,y,a,b;
int main() {
cin>>T;
while(T--)
{
cin>>n>>x>>y>>a>>b;
double petrolCost = x * ( ((double)n)/a );
double dieselCost = y * ( ((double)n)/b );
if(petrolCost < dieselCost)
cout<<"Petrol\n";
else if(petrolCost > dieselCost)
cout<<"Diesel\n";
else
cout<<"Any\n";
}
return 0;
}
```

## Tester's Solution

```
for _ in range(int(input())):
n, x, y, a, b = map(int, input().split())
if x*b == y*a:
print('any')
elif x*b < y*a:
print('petrol')
else:
print('diesel')
```