Please note that the return value of the ceil function is not an integer, but a float / double / long double.
When you use cout output, your ceil may return a value of 8.49371e+06 instead of 8493712.
If you want to use its return value for output, you need to convert it to an integer first.
Yesterday, I encountered this problem while working on problem B of Codeforces Round 926 (Div. 2), and I took a penalty and searched for the error for a long time (246502057 and 246508172).
It's really bad.
I hope what I said is helpful to you, XD.
you can do ceil without using the ceil function by doing this
lets say you want to ceil ( k / n ) so instead of writing ceil( k / n ) write this (k+n-1) / n
Yes, this is also a good solution.
This chain of comments might help.
Thank you!
This has been said so many times, I'm really surprised you got to CM without knowing you shouldn't use floating point functions on integers...
Also another cool and simple to memorize way to do ceil is n/k + (n%k!=0)
nice move .
or you can use (n+k-1)/k
i made the same error yesterday while attempting div2 contest .
ahhahahha same immediately fixed it and got ac ahahhaha
Fr, biggest setback for me when A had wrong answer for me in yesterday's Div 2, I panicked too much after that (not a good habit but I can't help) and ended up submitting 2 more wrong submissions. Had I submitted correct A at once, I would have had a positive rating change instead of the negative one yesterday :(
if i divide like this ceil(k/double(n)), then??