Marks :100
: 2 | : 3
In a premier championship series of sports car racing, initially, the 1st car is ahead of the 2nd car by X metres. After that, every second, the 1st car moves ahead by n1 metres and the 2nd can move ahead by n2 metres (in the same direction).
The task is to print the number of seconds after which the 2nd car crosses the 1st car. If it is impossible to do so, then print -1
The first line of the test case contains 3 integers separated by space n1,n2 and X. ($$$1 \le n1 \le n2 \le 10^5 $$$),($$$ 0 \le x \le 1000$$$) . where n1 and n2 are the distance travelled by car1 and car2 in one second and X is the distance by which car1 is ahead of car2
For each test case print, the time taken by car2 to overtake car1 or print -1 is car2 never able to move ahead of car1.
3 4 1
2
5 4 1
-1
2 12 15
2
Taking 1st test case as an example :
Initially, the 1st car is ahead by 1 metre.
After the 1st second, the 1st and 2nd cars are at the same place.
After the 2nd second, the 2 car moves ahead of the 1st car by 1 metre.
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.