The Mango Truck Python Solution Codechef

 

The Mango Truck Problem Code: MANGOES
Submit

You are given that a mango weighs X kilograms and a truck weighs Y kilograms. You want to cross a bridge that can withstand a weight of Z kilograms.

Find the maximum number of mangoes you can load in the truck so that you can cross the bridge safely.

Input Format

  • First line will contain T, the number of test cases. Then the test cases follow.
  • Each test case consists of a single line of input, three integers X,Y,Z - the weight of mango, the weight of truck and the weight the bridge can withstand respectively.

Output Format

For each test case, output in a single line the maximum number of mangoes that you can load in the truck.

Constraints

  • 1T1000
  • 1XYZ100

Sample Input 1 

4
2 5 11
4 10 20
1 1 1
6 40 90

Sample Output 1 

3
2
0
8

Explanation

Test case 1: You can load 3 mangoes at maximum. The total weight is 3×2+5=1111. Thus, the truck can safely cross the bridge with 3 mangoes. If you load 4 mangoes, the total weight is 4×2+5=13>11.

Test case 2: You can load 2 mangoes at maximum. The total weight is 2×4+10=1820. Thus, the truck can safely cross the bridge with 2 mangoes.

Test case 3: You can load 0 mangoes at maximum. The total weight is 0×1+1=11. Thus, the truck can safely cross the bridge only if there are 0 mangoes.

Test case 4: You can load 8 mangoes at maximum. The total weight is 6×8+40=8890. Thus, the truck can safely cross the bridge with 

# cook your dish here
t = int(input())
for _ in range(t):
    x,y,z= map(int,input().split())
    n = (z-y)/x
    r = int(n)
    print(r)

Post a Comment

0 Comments