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

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

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

1 | tourist | 3434 |

2 | Petr | 3353 |

3 | OO0OOO00O0OOO0O0…O | 3314 |

4 | fateice | 3306 |

5 | Um_nik | 3286 |

6 | Syloviaely | 3274 |

7 | dotorya | 3145 |

8 | LHiC | 3114 |

9 | Radewoosh | 3098 |

10 | mnbvmar | 3096 |

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

1 | tourist | 178 |

2 | rng_58 | 166 |

3 | Petr | 155 |

3 | csacademy | 155 |

5 | Swistakk | 149 |

5 | lewin | 149 |

7 | Um_nik | 142 |

8 | Errichto | 140 |

9 | matthew99 | 138 |

10 | Vovuh | 137 |

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: Jun/22/2018 19:45:23 (d2).

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