Блог пользователя black_moon_

Автор black_moon_, история, 4 года назад, По-английски

Hello All, I was trying to do an old problem Problem Link where I got the wrong answer for a testcase while submitting the solution and I ran the same testcase on few other compilers, I got the correct answer. Here are the links to results from ideone, codeforces, geeksforgeeks and (unable to attach image) for the solution Solution Link .

Please help if anyone knows the reason.
  • Проголосовать: нравится
  • -7
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится
cout << int(ans) << endl;

You are rounding floating point values...

If answer is integer, so the double should be around an integer, then to get best rounding, use int(ans+0.5);