Блог пользователя Nuu

Автор Nuu, история, 6 лет назад, По-английски

Hi guys, Today i sees a apparently easy math problem (but i can't solved):

Two persons walk simutanious around two circles with size A and B with positions [1,2,3,...,A] and [1,2,3,...,B].

Then follow Q querys. Each query give two positions x and y, and asks the number of step for person A arrive on position x and person B arrive on position y (on same time) using O(1).

Thanks guys, i'm very novice in math problems.

  • Проголосовать: нравится
  • -3
  • Проголосовать: не нравится

»
6 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

It asks for a question like k mod A = x and k mod B = y. This is Chinese remainder theorem application.

»
6 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

Dear Nuu,

The equivalent Chinese Remainder problem is: Find the smallest positive integer 0 <= n <= A*B - 1 such that n mod A = x - 1 and n mod B = y - 1.

Best wishes,