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

Автор arpitP, история, 4 года назад, По-английски

This is the problem of cses coin piles I have only one doubt why we have to check for this condition min(a, b) * 2 >= max(a, b)? and other approaches and hints will be highly appreciated.

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

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

No we dont need that condition

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

You can construct the equation system and find out. The solution must be nonnegative integers.

Let x be the number of moves that remove one coin from the left pile and two coins from the right pile. Let y be the number of moves that remove two coins from the left pile and one coin from the right pile. This yields a system of equations that you can solve: a = x + 2y, b = 2x + y. Through solving the system, you can rederive the condition you mentioned.