naevis's blog

By naevis, history, 5 years ago, In English

https://codeforces.com/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..

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
5 years ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

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)