Блог пользователя Mr.ink

Автор Mr.ink, 10 лет назад, По-английски

For problem 439D there is a ternary search solution that works very well but this is a ternary search on integers and it can go into an endless loop but the author of questions says it works correct.Why does this solution work?if hi = 3 , lo = 1 when answer is 2 ?The ternary search in this state can not reach 2. here is the code http://codeforces.com/contest/439/submission/6814294

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

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

for (int it = 0; it < 100; it++)

there are no endless loop, cause only of 100 iterations.

  • »
    »
    10 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    You are right but look if hi = 3 and lo = 1 and answer is 2 then it can not reach 2 and will print 3;