Car Range Code Chef.

Posted on | Friday, 19 May 2023 | No Comments

 

Problem

The fuel economy of a car is the distance which it can travel on one litre of fuel.

The base fuel economy (i.e, its fuel economy when there is only one person - the driver - in the car) of a certain car is  kilometres per litre. It was also observed that every extra passenger in the car decreases the fuel economy by 1 kilometre per litre.

 people want to take this car for a journey. They know that the car currently has  litres of fuel in its tank.

What is the maximum distance this car can travel under the given conditions, assuming that all  people always stay in the car and no refuelling can be done?

Note that among the  people is also a driver, i.e, there are exactly  people in the car.

Input Format

  • The first line of input contains a single integer , denoting the number of test cases. The description of  test cases follows.
  • Each test case consists of a single line of input, containing three space-separated integers ,, and  - the number of people, base fuel economy, and amount of fuel present in the car, respectively.

Output Format

For each test case, output a single line containing one integer - the maximum distance that the car can travel.

Constraints

  • 13104
  • 15
  • 656
  • 1100

Sample 1:

Input
Output
3
5 10 20
1 6 10
4 6 1
120
60
3

Explanation:

Test Case 1: There are 5 people in the car, and its base fuel economy is 10. Thus, its effective fuel economy is 104=6, since there are 4 people present other than the driver. There are 20 litres of fuel in the car, so the maximum distance that can be travelled is 620=120.

Test Case 2: The effective fuel economy is 6, and the maximum distance that can be travelled is 610=60.

Test Case 3: The effective fuel economy is 3, and the maximum distance that can be travelled is 31=3.

CODE:

for i in range(int(input())):

    a,b,c=map(int,input().split())

    if a>1:

        print((b-(a-1))*c)

    else:

        print(b*c)

Comments

Leave a Reply

Search

Followers