I think it has happened a while ago on codeforces itself, but I forgot the reason why this happens:
See this code and code below.
http://ideone.com/N7vzQ
and added 1 "cout" to the code at 119 and result changes:
http://ideone.com/OXHpO
By adding cout <<" "; should not change 39 to 2. :|
My guess is , its compilers problem.
Thanks in Advance.
If yes, it's very common effect. Optimizer is guilty. This cout 'foribs' optimization of some code. It can change execution result, if you have arrays overflow or something like this.
Try to compile the first one without optimization and compare results.
Yes , you are right , Optimizer is guilty.
In that case, if we are participating in online contest(where we cannot modify compiler-options) , shall we use "eps" as Alias told?
But that means whenever I will compare doubles , I will have to use eps,
that sounds like a headache. :(