Be careful when using ceil() in C++ :(

Правка en1, от TLE_Automaton, 2024-02-16 05:37:40

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.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский TLE_Automaton 2024-02-16 05:37:40 687 Initial revision (published)