Can anyone give me a hint to solve this problem https://codeforces.com/contest/1152/problem/C please? Thank you

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

1 | tourist | 3557 |

2 | Um_nik | 3494 |

3 | Radewoosh | 3344 |

4 | wxhtxdy | 3309 |

5 | LHiC | 3302 |

6 | Benq | 3286 |

7 | mnbvmar | 3274 |

8 | Petr | 3254 |

9 | yutaka1999 | 3190 |

10 | ksun48 | 3170 |

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

1 | Errichto | 191 |

2 | Radewoosh | 180 |

3 | PikMike | 166 |

4 | Vovuh | 165 |

5 | antontrygubO_o | 164 |

6 | rng_58 | 161 |

7 | Um_nik | 156 |

7 | majk | 156 |

9 | 300iq | 155 |

10 | farmersrice | 151 |

Can anyone give me a hint to solve this problem https://codeforces.com/contest/1152/problem/C please? Thank you

↑

↓

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/14/2019 03:03:52 (f3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

try to make gcd as large as possible; gcd(a,b)=gcd(b-a,a)

During the contest I too thought that making the gcd as large as possible might be optimal but we have to minimise the lcm which is equal to product of 2 numbers divided by the gcd. How does maximising the gcd ensures minimum lcm. What is the mathematical proof for this

yes, this was my question as well, how to guarantee that by maximizing the gcd , the lcm will be minimized and also how to know that gcd(8+k, 12+k) = 4 for example is as maximum as possible when k = 0.

hint 1let's suppose $$$a \leq b$$$, then $$$\gcd{(a + k, b + k)} = \gcd{(a + k, b - a)}$$$

hint 2$$$\gcd{(a + k, b - a)}$$$ is a divisor of $$$b - a$$$

hint 3for each $$$d$$$, divisor of $$$b - a$$$, we are trying to find such k that $$$\gcd{(a + k, b - a)} = d$$$

one more hint?

is a divisor ofd+a, so there is a integerkthatn+a=k*n. Therefore,d=k*n—d. We also wantato be as small as possible, sokshould be as small as possible.n