Please read the new rule regarding the restriction on the use of AI tools. ×

Dark_Knight_3's blog

By Dark_Knight_3, history, 2 hours ago, In English

In the recent Codeforces Round 976 (Div. 2) and Divide By Zero 9.0 contest, I submitted my solution for 2020B - Brightness Begins in C++ 23. There, I got the wrong answer on G++ 23, but after the contest, I solved it by changing the language to G++ 17, and it got accepted. So what was the problem? Should I be using G++ 17 or G++ 23? What should be considered when using the built-in sqrt() function? Like precision, etc.. G++ 17 solution 283662762 G++ 23 solution 283597439

  • Vote: I like it
  • +5
  • Vote: I do not like it

»
2 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Dark_Knight_3 (previous revision, new revision, compare).

»
2 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Dark_Knight_3 (previous revision, new revision, compare).

»
2 hours ago, # |
  Vote: I like it +1 Vote: I do not like it

You should be using either sqrtl or binary search.

  • »
    »
    119 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    But the same code that got WA on 8 with G++ 23 got accepted with G++ 17. In that code, sqrt() worked. I was having this confusion.

    • »
      »
      »
      114 minutes ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      The sqrt function works using floating points. So maybe precision error varies among compilers.

    • »
      »
      »
      109 minutes ago, # ^ |
        Vote: I like it +2 Vote: I do not like it

      The same thing happened to me too XD