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

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

https://codeforces.net/gym/101911/problem/C . For each number in the array, I will merge each number from the array until it can't be merged, and then for each number in the array after it merged, I will multiply and then search for the number in the array, if it not found and the number is bigger than the maximum value on the array, then it will be no answer, I got wrong answer..

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

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

Auto comment: topic has been updated by naevis (previous revision, new revision, compare).

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

i dont really understood your aproach... but you can just always take the two smallest numbers $$$x$$$ and $$$y$$$, if $$$x = y$$$ insert $$$2x$$$ else insert $$$2x$$$ and $$$y$$$ and increase the result by one. if this terminates you definately found the correct result. If there is no solution this programm will not terminate. The non mathematical solution to handle this is to stop if $$$x$$$ becomes too big. The mathematical solution is to check if a solution does exist (all values have to be of the form $$$2^x$$$ min)