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 | 3600 |

3 | Benq | 3503 |

4 | ksun48 | 3421 |

5 | Um_nik | 3412 |

6 | Radewoosh | 3382 |

7 | maroonrk | 3323 |

8 | Itst | 3239 |

9 | apiadu | 3238 |

10 | ko_osaga | 3232 |

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

1 | Errichto | 205 |

2 | SecondThread | 197 |

3 | Monogon | 195 |

4 | vovuh | 189 |

5 | Um_nik | 185 |

5 | pikmike | 185 |

7 | antontrygubO_o | 184 |

7 | Ashishgup | 184 |

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/26/2020 18:44:50 (g1).

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**?