mbrc's blog

By mbrc, 11 years ago, In English

I found a soln. for 253B - Physics Practical which is 2726248 during the contest-it got error for test 14. But on my computer, when I tested the program for test 14 (given there), the answer was correct (the answer was also provided). In custom test, it gave wrong answer, but on my computer it gave correct answer. Why so?

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

»
11 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Because you use floating point numbers in the situation where integer calculations are enough.

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

Floating point number should be compared using some EPS. For example: To check if a < b you should write a + EPS < b. To check if a <= b you should write a <= b + EPS.

»
11 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Thank you