BiNarY_OVerFloW's blog

By BiNarY_OVerFloW, history, 3 years ago, In English

Here are my two submissions https://codeforces.com/contest/1484/submission/110870622 when i change ceil(m/2) with (m+1)/2 it got AC https://codeforces.com/contest/1484/submission/110882130 But i think ceil(m/2) and (m+1)/2 give same result... I can not figure out the reason.. Can anyone help? Any help would be highly appreciated... Thank You.

  • Vote: I like it
  • -16
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Ceil(m/2) If m is integer then the compiler will first do Integer division of m/2. Then will do the ceil operation. So, if m=3 then m/2 = 1 and ceil(1)=1. You can do ceil(m/2.0) instead.

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

ceil function is not so good for precision, also m / 2 returns integer as m is an integer

»
3 years ago, # |
  Vote: I like it +10 Vote: I do not like it

Any number like ceil(m/a)=(m+a-1)/a;