ManasXD's blog

By ManasXD, 7 hours ago, In English

Problem Link : 1995C - Squaring

I have tried to implement the float method from the editorial.

Editorial solution

I am using base 2 for log here. In the first code, I am calculating the difference of b[i-1] and b[i], tmp is the number of times log(2)=1 has to be added into b[i]. If b[i-1]-b[i]>0, We are adding it's ceil value to the total operations ( ops ) and also to b[i] itself.

However this solution gives wrong answer on test-case 2, my guess is my outputs are bigger than answer expected.

Note: I have removed input templates from codes to make them short, rest is intact. You can also refer to the submission links.

Code with wrong answer

code with ceil()

submission : 272991530

While this code works

working code

submission : 272991530

Full text and comments »

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