-55. The Robots

I'm a slow walker, but I never walk backwards.

題目來源:judgegirl from ntu prof. pangfeng Liu

Task Description

Write a program to predict the fate of two robots. Suppose we have two robots running in an (horizontal) by (vertical) unit grid. Both will move at the speed of one square per time step. The first robot carries amount of fuel and the second robot carries . If a robot runs out of fuel, it will stop at that square. Moving to a new square requires one unit of fuel. During the first time steps, the first robot will move to the north; then, it will move towards the east during the next time steps. The first robot will repeat this pattern until it runs out of fuel. The second robot will move a little bit differently. During the first time steps, the second robot will move to the east; then, it will move towards the north during the next time steps. Again the second robot will repeat this pattern until it runs out of fuel. If either robot moves "out of bound," it will "wrap around" and reappear (by sort of magic) on the other side of the field. For example, if and and a robot at goes north, it will reappear at . In addition, if two robots move into the same square, they explode. Now given the starting position of the first robot at , and the second robot at , and the amount of fuel they carry ( and ), determine whether the two robots will explode or not.

Input

There is only one line of inputs that contains , with the following constraints.

Output

There are two cases of output. If two robots explode, output robots explode at time T, where is the time they explode. Otherwise, output robots will not explode.

Sample input

7 6 2 0 9 2 100 3 5 2 7 100

Sample output

robots explode at time 5

Sample input

7 6 2 0 9 2 6 3 5 2 7 0

Sample output

robots will not explode

Poem

我知道我們屬於不同的世界. 我們追尋不同的方向. 我們依循不同的週期. 但是, 如果我願意用一輩子的時間等待. 那麼, 在我燈枯油盡之前. 我們是否能有 相逢的一天?

Submit

Login

Testdata Set

Download Testdata