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):
Using n/2 and n/2+1 (AC):

P.S.: I know the nesting could have been simplified. I just want to know why ceil and floor doesn’t work.
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!