Your text to link here...Anyone solved this one??

Please, try EDU on Codeforces! New educational section with videos, subtitles, texts, and problems.
×

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

1 | MiFaFaOvO | 3681 |

2 | tourist | 3669 |

3 | Um_nik | 3535 |

4 | 300iq | 3317 |

5 | ecnerwala | 3294 |

6 | maroonrk | 3268 |

7 | TLE | 3223 |

8 | scott_wu | 3209 |

9 | WZYYN | 3180 |

10 | boboniu | 3174 |

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

1 | Errichto | 197 |

2 | antontrygubO_o | 187 |

3 | pikmike | 182 |

3 | Ashishgup | 182 |

5 | vovuh | 179 |

6 | Radewoosh | 168 |

7 | Um_nik | 164 |

8 | tourist | 163 |

8 | Monogon | 163 |

10 | McDic | 162 |

Your text to link here...Anyone solved this one??

↑

↓

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jul/09/2020 02:42:33 (i2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

...which one?

Your text to link here... Problem J-ONCE UPON A TIME

Auto comment: topic has been updated by ankit_18 (previous revision, new revision, compare).Your link in the original post is broken :(

You can solve that problem using the Chinese Remainder Theorem. You want to find the first time they collide x where:

Once you have this x, you can add the LCM of m and a to x until it is >= max(n, k). (you can math the second part out to solve it in O(1), plus CRT stuff)

Thanks Can u explain it more in psuedo code format please??

No man, I'm not going to write out psuedocode that solves the Chinese remainder theorem for you after I just gave you a link to learn it if you won't even fix the link on your question.

Here is a good youtube tutorial which helped me learn it, if you struggle reading through the Wikipedia article.

If what I wrote still doesn't make sense after you understand CRT, then this is probably a little bit too difficult of a problem for you to be solving at the moment. It might be more helpful to practice on easier problems until you are a bit more comfortable on implementation and then come back to this in a few weeks or so.

Yes you r ri8..I should solve the easier problem first btw thanks for ur time