Codechef•Jun 08, 2025
Mario and Bullet
Hazrat Ali
Codechef
Mario's bullet moves at XX pixels per frame. He wishes to shoot a goomba standing YY pixels away from him. The goomba does not move.
Find the minimum time (in seconds) after which Mario should shoot the bullet, such that it hits the goomba after at least ZZ seconds from now.
Input Format
- The first line of input will contain an integer T, the number of test cases. Then the test cases follow.
- Each test case consists of a single line of input, containing three space-separated integers X,Y, and Z.
Output Format
For each test case, output in a single line the minimum time (in seconds) after which Mario should shoot the bullet, such that it hits the goomba after at least ZZ seconds from now.
Constraints
- 1≤T≤100
- 1≤X,Y,Z≤100
- XX divides YY
Sample 1:
Input
3 3 3 5 2 4 1 3 12 8
Output
4 0 4
Solution
t = int(input())
for _ in range(t):
x, y, z = map(int, input().split())
if x == y:
print(z - 1)
elif y // x > z:
print(0)
else:
print(z - (y // x))