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.

# | User | Rating |
---|---|---|

1 | tourist | 3687 |

2 | ecnerwala | 3668 |

3 | Benq | 3503 |

4 | ksun48 | 3421 |

5 | Um_nik | 3412 |

6 | Radewoosh | 3382 |

7 | maroonrk | 3323 |

8 | ainta | 3318 |

9 | Itst | 3239 |

10 | apiadu | 3238 |

# | User | Contrib. |
---|---|---|

1 | Errichto | 204 |

2 | SecondThread | 200 |

3 | Monogon | 196 |

4 | vovuh | 189 |

5 | Um_nik | 186 |

5 | pikmike | 186 |

7 | antontrygubO_o | 184 |

8 | Ashishgup | 181 |

9 | pashka | 169 |

10 | Radewoosh | 167 |

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.

↑

↓

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Nov/30/2020 10:56:49 (f3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

No we dont need that condition

My waythank you but i am not able to understand your code

At which part ? :(

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.

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

conditions2*a>=b

2*b>=a

but from where max and min is coming into picture?

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

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