ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2102. Michael and Cryptography

WrongAnswer #28
Posted by GOR ABELYAN 29 May 2020 03:19

Edited by author 29.05.2020 13:26

Edited by author 29.05.2020 13:26
Re: WrongAnswer #28
Posted by Levon Oganesyan 29 May 2020 03:36
Try to change this
for (int i = 3; i <= Convert.ToInt32(Math.Ceiling(BigInteger.Log(n, 2))); i += 2)
to this
for (BigInteger i = 3; i * i <= n; i += 2)

Btw, you do not need BigInteger here, long is enough.

Edited by author 30.05.2020 21:39
Re: WrongAnswer #28
Posted by Levon Oganesyan 29 May 2020 03:39
After this you will receive TLE39, try to handle the case with two big multiplied prime numbers, for example 1000000007*1000000009.

Edit: this is even easier, than I thought. Just change your for to
for (BigInteger i = 3; i < 10000000; i += 2)

Edited by author 29.05.2020 03:42

Edited by author 29.05.2020 03:42
Re: WrongAnswer #28
Posted by GOR ABELYAN 29 May 2020 13:26
Thanks a lot,