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

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

I know that this problem supposed to be a trivial problem , but I stay in it about 1 hour and i don't know why it get WA on test 3 about 10 times of submissions and i submitted the solution with python and c++ as i thought that WA is due to precision error but both of them didn't get accepted.
Any help please?

c++ code
python code
  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

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

It is about rounding, you have to set value = (dist * 1000.0) / (331.3 + .606 * temp), and then to round you have to floor(value*100+0.5)/100; Then it gets AC.

  • »
    »
    22 месяца назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится

    thank you, my code get accepted in python and c++ also.

  • »
    »
    22 месяца назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится

    This still gives me wrong answer. What am I doing wrong?

    Code
    • »
      »
      »
      22 месяца назад, # ^ |
        Проголосовать: нравится +6 Проголосовать: не нравится

      You don't use setprecision after rounding, due to it changing the answer. It gets AC when you remove fixed and setprecision(2).

    • »
      »
      »
      22 месяца назад, # ^ |
        Проголосовать: нравится +3 Проголосовать: не нравится

      your code will be accepted if you print value without setprecision and fixed, but i don't know why these happened.

      accepted code