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

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

Please subscribe to the official Codeforces channel in Telegram via the link: https://t.me/codeforces_official.
×

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

1 | Radewoosh | 3443 |

2 | tourist | 3372 |

3 | OO0OOO00O0OOO0O0…O | 3264 |

4 | ksun48 | 3176 |

5 | scott_wu | 3168 |

6 | CongLingDanPaiSh…5 | 3157 |

7 | Benq | 3154 |

8 | Petr | 3139 |

9 | Um_nik | 3138 |

10 | LHiC | 3118 |

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

1 | Radewoosh | 195 |

2 | Errichto | 176 |

3 | rng_58 | 158 |

4 | Ashishgup | 157 |

5 | neal | 156 |

6 | tourist | 154 |

7 | Petr | 151 |

8 | PikMike | 150 |

9 | Um_nik | 149 |

10 | kostka | 147 |

10 | Swistakk | 147 |

10 | Vovuh | 147 |

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: Dec/12/2018 14:09:10 (d3).

Desktop version, switch to mobile version.

Supported by

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