codeforces 1304A. Two Rabbits


Problem link

A solution in c++



Post a Comment

2 Comments

  1. Can you just explain the problem's answer? why n = y - x and m = a + b

    ReplyDelete
    Replies
    1. 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.

      Delete

If you have any doubts, Please let me know