Menu

Informatics Задача №112688. Новоселье

February 17, 2017 - informatics.mccme.ru

Language: C++

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

typedef double real_t;

#define TASKNAME "d"

int
main()
{
    int x0, y0;
    int x1, y1;
    int x2, y2;
    cin >> x0 >> y0;
    cin >> x1 >> y1;
    cin >> x2 >> y2;
    int dx1 = abs(x1 - x0);
    int dx2 = abs(x2 - x0);
    real_t res = 0.;
    real_t d1 = dx1 / (y0 - y1 + 0.) * y0;
    real_t d2 = dx2 / (y0 - y2 + 0.) * y0;
    real_t h0 = y0;
    real_t h1 = y1;
    real_t h2 = y2;;
    if (h1 > h2) {
        // swap points over indices
        swap(h1, h2);
        swap(d1, d2);
        swap(dx1, dx2);
        swap(x1, x2);
        swap(y1, y2);
    }
    { // when rectangle doesn't touch "borders"
        real_t argmax = max(h2, h0 / 2.);
        res = max(res, argmax * (d1 + d2) * (1 - argmax / h0));
    }
    cout << fixed << setprecision(10) << res << endl;
    return 0;
}

(25)

It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on VK

Author of this post : UnknownA AuthorA

Leave a Reply

Your email address will not be published. Required fields are marked *