Same logic, one gives WA, other AC in CONFLIP

Can somebody please explain why there is a difference if we use n/2 and n/2+1 in place of floor(n/2.0) and ceil(n/2.0)? I got WA for using floor and ciel and AC for using n/2+1 logic.

Using floor and ciel (WA): https://www.codechef.com/viewsolution/33021154
Using n/2 and n/2+1 (AC): https://www.codechef.com/viewsolution/33021546

P.S.: I know the nesting could have been simplified. I just want to know why ceil and floor doesn’t work.

https://www.codechef.com/viewsolution/33024131
Fixed it.
ceil and floor return doubles, so it might get printed as 1.2e6 or something like that, that’s why you need cout<<fixed<<setprecision(0); to print it like an int. secondly, though not important here, always add a small constant when doing floor, and subtract a small constant while doing ceil, because there are errors in floating point arithmetic.

Thank you!