beethoven97's blog

By beethoven97, history, 12 days ago, In English

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
 
 
 
 
  • Vote: I like it
  • +3
  • Vote: I do not like it

»
12 days ago, # |
  Vote: I like it +6 Vote: I do not like it

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.

  • »
    »
    12 days ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

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

  • »
    »
    12 days ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

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

    Code
    • »
      »
      »
      12 days ago, # ^ |
        Vote: I like it +6 Vote: I do not like it

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

    • »
      »
      »
      12 days ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

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

      accepted code