Georeth's blog

By Georeth, history, 4 years ago, In English

SGU-151

Exactly the same code, GNU C++11 got WA on test #19 75830647, GNU C++14 got AC 75830595. I submitted 30 times to find the problem.

#include <cstdio>
#include <cmath>
static const double EPS = 1e-13;
int main() {
    double c, b, m; scanf("%lf%lf%lf", &c, &b, &m);
    double c2 = c * c, b2 = b * b, m2 = m * m;
    double a2 = 2 * (b2 + c2) - 4 * m2;
    if (a2 < 0) {
        printf("Mission impossible");
        return 0;
    }
    double a = sqrt(a2);
    if ((a + b < c) || (a + c < b) || (b + c < a)) {
        printf("Mission impossible");
        return 0;
    }
    double x = (c2 - b2) / (2 * a);
    if (fabs(a) < EPS) x = 0;
    double y = sqrt(m2 - x * x);
    printf("%.5lf %.5lf\n",x,y);
    printf("%.5lf %.5lf\n",-(a)/(double)2.0,(double)0);
    printf("%.5lf %.5lf",(a)/(double)2.0,(double)0);
    return 0;
}

I hope the Codeforces maintainers verify the test data and my report of SGU-124

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

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

Auto comment: topic has been updated by Georeth (previous revision, new revision, compare).