arpit92_8's blog

By arpit92_8, history, 9 days ago, In English

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.

 
 
 
 
  • Vote: I like it
  • +4
  • Vote: I do not like it

»
9 days ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

No we dont need that condition

My way
»
9 days ago, # |
  Vote: I like it +3 Vote: I do not like it

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.

  • »
    »
    8 days ago, # ^ |
    Rev. 3   Vote: I like it 0 Vote: I do not like it

    thank you for the reply i understand your concept up to some extent om solving the eqns i am getting two condition

    conditions

    but from where max and min is coming into picture?

»
9 days ago, # |
  Vote: I like it 0 Vote: I do not like it

take both piles mod 3 then hardcode in 2-1 2-0 etc

  • »
    »
    8 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    thank you for the reply but i couldnt understnd the line ** hardcode in 2-1 2-0 etc**?