### PersistentProgrammer's blog

By PersistentProgrammer, history, 2 weeks ago, ,

Recently, I was trying to solve the problem: 1288A - Deadline The submission: 68862578 The submission got accepted. If the compiler is changed to "GNU C++14" with the same code it gives the wrong answer in test 22; also, on test 50 it will give the same wrong answer it will output ("YES \n YES \n") I don't know which line that made the compilers give different output. Submission with "GNU C++14": 68867586 I tried to optimize the solution by this submission: 68864007 it gave the output ("YES \n YES \n") in test 50 No matter which compiler used. could anyone explain this behaviour? update: I found the problem. the problem was in using float instead of double. So, float accuracy was less than double.

• -4

 » 2 weeks ago, # |   0 Auto comment: topic has been updated by PersistentProgrammer (previous revision, new revision, compare).
 » 2 weeks ago, # | ← Rev. 5 →   +5 Changing the following floating-point expression ceil(d/float(m+1)) to ceil(d/double(m+1)) was sufficient to get your code accepted in C++14 68870201. You can avoid the floating-point approximation error issue by using integer division 68870731. (d+m)/(m+1) as it is well known that the ceiling function of the ratio $x/y$ when $x$ and $y$ are positive integers, $\lceil x/y \rceil$, is equal to the quotient of the integer division $(x+y-1)/y$.