Problem Link: https://uva.onlinejudge.org/external/125/12546.pdf

Solution Link: https://ideone.com/q2SX1x

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

1 | tourist | 3509 |

2 | OO0OOO00O0OOO0O0…O | 3327 |

3 | Syloviaely | 3274 |

4 | Um_nik | 3237 |

5 | Petr | 3161 |

6 | fjzzq2002 | 3137 |

7 | LHiC | 3135 |

8 | Benq | 3130 |

9 | ko_osaga | 3115 |

10 | Swistakk | 3089 |

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

1 | Radewoosh | 185 |

2 | rng_58 | 161 |

3 | tourist | 158 |

4 | Petr | 152 |

5 | Swistakk | 150 |

5 | Vovuh | 150 |

7 | Um_nik | 149 |

8 | PikMike | 147 |

9 | csacademy | 146 |

10 | Errichto | 145 |

Problem Link: https://uva.onlinejudge.org/external/125/12546.pdf

Solution Link: https://ideone.com/q2SX1x

↑

↓

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Sep/26/2018 02:56:33 (f1).

Desktop version, switch to mobile version.

User lists

Name |
---|

Finally I solved it . From seeing your code I can guess that you are constructing all pairs of integers whose LCM is

n. But the problem is that there are an exponential number of possibilities .My approach was the following , first notice that

pandqare always the divisors ofnalso you can create equivalence classes forp. Ifn=p_{1}^{pow1}* ...p_{k}^{powk}is the prime factorisation ofn, then we partition all the divisors into equivalence classes such that a particular equivalence class contains a subset of prime divisors to their highest power and other prime divisors can have smaller powers . For each of the equivalence class inpwe consider how many numbersqcan be created such thatlcm(p,q) =n.This is the abstract of my approach , Take a look at my CODE