Can anyone tell me the logic of the code from AtCoder?
source link: http://codeforces.com/blog/entry/109804
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
In yesterday's AtCoder Beginner Contest 280 I didn't able to solve D. Then I was looking for solution and after seeing this submission I was shocked. Can anyone tell me how the logic work for this problem submission?
Thanks.
Suppose kk is a prime, then, the answer is always kk. If kk is composite, remember that if a divisor an integer nn is less than or equal to n−−√n, the other divisor is greater than or equal to n−−√n. The solution uses that idea. The limit is 2⋅1062⋅106, you can get a better limit by figuring out the last prime smaller than 106106(which is 999983999983) and multiply by 22. Why multiply by 22? Because we can get a square of that prime as an input for kk(which means that the answer would be prime∗2prime∗2). Check the answer for k=1999966k=1999966 with limit=106limit=106 to get what I mean and why the limit should be at least 19999661999966. |
Here is an alternative approach. Suppose Edit: Just realized OP was referring to a particular submission. |
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK