BrendonSlash's blog

By BrendonSlash, history, 8 years ago, In English

For this problem http://codeforces.com/problemset/problem/492/B. I've used a binary search approach to get a solution. However, I'm getting an incorrect result in the floating points for the answer. How can I overcome this.

This is my solution http://codeforces.com/contest/492/submission/17201833

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

»
8 years ago, # |
Rev. 10   Vote: I like it 0 Vote: I do not like it

First of all, you must output using "fixed" floating format, which says to output system to print N digits after the '.'

cout << fixed << setprecision(6) << d;

Also, the problem statement says, that 9 digits are significant in the answer, so it would be better to output using setprecision(9). Double data type gives 15-17 significant digits, so it's enough, I think

UPD: Checker is quite funny, this verdict looks really weird

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

    "fixed" isn't necessary, setprecision(20) is enough for this case.