Stop and Run !

oorpib STP Coding Test 31 Dec 20...
Limits 1s, 512 MB

Have you watched the movie “Forest Gump “ ? There’s a famous quote “Run! Forest, Run!”

Belal has recently watched this movie. Now he is feeling like running.
He asked his friend Amin to run a race. Amin accepted the challenge.

Belal set some rules.

At once only one will run i.e if Belal is running Amin is waiting, and vice versa.

The Total Running Distance they will run (D meters) is predefined and this may vary person to person (not fair ?) . Whoever reaches their Total Distance’s first, he will win the race !

Each of them can run a fixed distance at once (R). There's a bonus run distance (B)!

At every 5th run, they can use the Bonus run.
The first one to start running is decided by a coin toss (X).

Let say Amin wins the toss, so he will start running, After running
R meters Amin will stop (I don’t know how they will manage to calculate the exact distance ! ) and Belal will start running next following the same method.

However, when someone completes his each 5th run, he will run some Bonus Distances (initially B). And then the Bonus Distance B will be increased by 1.
For Example, if Amin gets a bonus distance of 6 meters after his 5th run, this will be increased to 7(6+1) meters after his 10th run and so on.

As Amin is a great Programmer he can calculate if he can win . And he won't bet if he fails to win. Given each of their Total Running Distances (D), Fixed Distance to run at once (R), Bonus Distance (B), and the winner of the coin toss (X).
Can you solve it too ???


The first line contains the number of test cases T (1≤ T ≤ 100000). For each test case the first line contains X ( X = 0 or 1), 0 if Belal won the toss, and 1 if Amin won the toss.

The next two lines contain the description of their running factor D, R, B ( 1≤ D ≤ 10^10 , 1≤ R ≤ 10^10, 1≤ B ≤ 10^10), First being the description of Amin’s, the second is the description of Belal’s. ( I don't know how they will run the these long distance , may be they have some SuperPowers ! And Of course SUPERSTAMINA !!)


For each test case print ‘yes’ (without the quotes) if Amin can win or ‘no’ (without the quotes) if he can’t win in the separate line. Output is case-sensitive.


46 10 7
67 20 7
46 10 7
108 20 7

The first case, Amin starts running first and his total distance covered with consecutive moves are as follows →10 20 30 40 57

And total distance covered by Belal with consecutive moves are as follows → 20 40 60 67

As Belal needs less step / turn , Amin loses.

As for Second case Belal starts running first ,
his total distance covered with consecutive moves will be → 20 40 60 80 107 127

As Amin needs less step / turn , he wins .


Login to submit.


80% Solution Ratio
mahfuz007Earliest, Dec '20
AungkurFastest, 0.0s
TUSHAR_BDLightest, 512 kB
robiulRonyShortest, 1036B
Toph uses cookies. By continuing you agree to our Cookie Policy.