Your text to link here...Anyone solved this one??
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3839 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3612 |
7 | Geothermal | 3569 |
7 | cnnfls_csy | 3569 |
9 | ecnerwala | 3494 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | Um_nik | 164 |
2 | maomao90 | 160 |
3 | -is-this-fft- | 159 |
4 | atcoder_official | 158 |
4 | awoo | 158 |
4 | cry | 158 |
7 | adamant | 155 |
8 | nor | 154 |
9 | TheScrasse | 153 |
10 | maroonrk | 152 |
Your text to link here...Anyone solved this one??
Название |
---|
...which one?
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