In-game bullet

A bullet in game moves at X pixels per frame.We wish to hit a target standing Y pixels away from us. The target does not move.

Find the minimum time (in seconds) after which you shoot the bullet, such that it hits the target after at least Z seconds from now.
        
       Input:-3
3 3 5
2 4 1
3 12 8
       Input Description: 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: 4
0
4
       Output Description: For each test case, output in a single line the minimum time (in seconds) after which you should shoot the bullet, such that it hits the target after at least Z seconds from now. 
       Constraints: 1<=T<=100
1<=X,Y,Z<=100
X divides Y
       Explanation: Test case 1: The speed of the bullet is 3 pixels per frame and the target is 3 pixels away from you. Thus, it would take 1 second for the bullet to reach the target. You want the bullet to reach target after at least 5 seconds. So, he should fire the bullet after 4 seconds.

Test case 2: The speed of the bullet is 2 pixels per frame and the target is 4 pixels away from you. Thus, it would take 2 seconds for the bullet to reach the target. You want the bullet to reach the target after at least 1 second. So, you should fire the bullet after 0 seconds. Note that, this is the minimum time after which he can shoot a bullet.

Test case 3: The speed of the bullet is 3 pixels per frame and the target is 12 pixels away from you. Thus, it would take 4 seconds for the bullet to reach the target. You want the bullet to reach target after at least 8 seconds. So, he should fire the bullet after 4 seconds.

Loading...