1034A - Enlarge GCD There has been no editorial after the contest . so can someone help me to solve this problem ?

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

1 | tourist | 3581 |

2 | OO0OOO00O0OOO0O0…O | 3264 |

3 | mnbvmar | 3246 |

4 | Um_nik | 3194 |

5 | LHiC | 3190 |

6 | Petr | 3161 |

7 | V--o_o--V | 3133 |

8 | CongLingDanPaiSh…5 | 3116 |

9 | ko_osaga | 3115 |

10 | Benq | 3098 |

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

1 | Radewoosh | 185 |

2 | Errichto | 164 |

3 | rng_58 | 161 |

4 | tourist | 158 |

5 | Vovuh | 150 |

5 | Um_nik | 150 |

7 | Swistakk | 149 |

7 | Petr | 149 |

9 | PikMike | 148 |

10 | 300iq | 147 |

10 | neal | 147 |

1034A - Enlarge GCD There has been no editorial after the contest . so can someone help me to solve this problem ?

↑

↓

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/19/2018 11:12:01 (f1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

Suppose the gcd of the initial array is x. Divide every element by x. Now you simply find the largest subset which has gcd > 1.

43212157 I have tried this idea but i got a TLE . I am wondering if it can be improved

your gcd implementation is bugged.try this

You could also use the __gcd(a,b) function in the bits/stdc++.h library

how can we find the largest subset for which gcd>1 ?

For the remaining elements in our group, we have some prime p that divides them all, since otherwise their gcd would be one. Therefore, the prime is also ≤ 1.5 * 10

^{7}.You can just find all primes below that bound, and then count how many different numbers that prime appears in. To do this, just factor every a_i, and increment the primes's counters that appear in its factorization.

But how can we prove ,new gcd is greater than old gcd

Because we divided all elements with old gcd, old gcd is 1. New gcd is >= p, with the prime we choose, so it is greater than the old gcd.

I am not able to get this, can you explain a bit more or attach any link from where i can understand this.

In their test no 4 , their input is: 2 1 7 with ans 1 which means 1 removal but according to this doesn't the answer become n-(no of occurrences of maximum element of the array)