Because a 🐇 jumps to the right, b 🐇 jumps to the left, so if a is on the right of b at the beginning, directly -1.
If the sum of the distances between a and b is not divisible by the sum of the distances of a and b in one hop, then directly -1. Output the divisor if it is divisible.
2 Comments
Can you just explain the problem's answer? why n = y - x and m = a + b
ReplyDeleteBecause a 🐇 jumps to the right, b 🐇 jumps to the left, so if a is on the right of b at the beginning, directly -1.
DeleteIf the sum of the distances between a and b is not divisible by the sum of the distances of a and b in one hop, then directly -1. Output the divisor if it is divisible.
If you have any doubts, Please let me know