Блог пользователя Phobiceron

Автор Phobiceron, история, 6 лет назад, По-английски

86827890 problem:https://codeforces.me/contest/1372/problem/B it says TLE on the 4th test case. Can someone please help me to find a better solution.Thanks in advance.

p.s.:sorry if this isn't how you are supposed to use blogs, i wasn't sure where to post doubts in this website.

  • Проголосовать: нравится
  • -9
  • Проголосовать: не нравится

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

For odd numbers you are checking till n/2 making the complexity O(n). The constraints are too high for O(n). Try doing it in O(sqrt(n))

»
6 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +18 Проголосовать: не нравится

There are several thousend working solutions and a tutorial

You are supposed to have a look into that resources.