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

Автор mbrc, 11 лет назад, По-английски

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?

  • Проголосовать: нравится
  • -5
  • Проголосовать: не нравится

»
11 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

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

»
11 лет назад, # |
  Проголосовать: нравится +7 Проголосовать: не нравится

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 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Thank you