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

Автор ClosetNarcissist, история, 12 месяцев назад, По-английски

So I was solving this problem https://mirror.codeforces.com/gym/105723/problem/F

and wrote this solution https://ideone.com/SNfGJ6

It works fine in my laptop and ideone C++ 14 but when I submitted it in C++17 (GCC 7-32) I got WA on test 1. It did not make sense to me how I got a vastly different result on the test case in my laptop and CF. I suspected some type of RTE but I could not find any. Then I just submitted in C++23 (GCC 14-64, msys2) and got AC even though I did not change anything in the code.

Anyone knows why this happened. I feel like knowing it would kind of help me avoid it in contests. idk -_-

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

»
12 месяцев назад, скрыть # |
 
Проголосовать: нравится +13 Проголосовать: не нравится

I suspect this has something to do with floating point precision error. G++23 has a 64 bit judge, therefore the floats are more accurately represented. Try to avoid floats as much as possible if you can