priyanshu_28's blog

By priyanshu_28, history, 2 years ago, In English

During Educational Codeforces Round 116 (Rated for Div. 2), I try to submit my solution for question c in c++20 when there were around 850 submissions. But due to some reason, I kept getting the wrong answers. When I submitted it in c++17, it got accepted. You can see my submissions. Kindly look into this matter, I want to point out the bug rather than focusing on anything else. MikeMirzayanov

  • Vote: I like it
  • -24
  • Vote: I do not like it

| Write comment?
»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

What is the difference between log(k)/log(2) and log2(k)? Because in B problem it gives wrong answer if I use first one.

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

    because C++ isn't your CASIO calculator, it has to work with precisions

»
2 years ago, # |
  Vote: I like it +7 Vote: I do not like it

Most likely the pow function here is the culprit. Even if both of its arguments are integers, it still works with non-integer types, so it sometimes causes precision issues. Source

Your solution would've worked if you had made a power function of your own. Or what you did, shifting from 64bit to 32bit compiler.

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

    The funny thing is if the compiler rounded down the value it makes sense. It actually printed a bigger answer.