Cod sursa(job #2507356)

Utilizator DumitresculEDumitrescul Eduard DumitresculE Data 10 decembrie 2019 08:46:17
Problema Aria Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.07 kb
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("aria.in");
ofstream fout ("aria.out");
struct str{
    double x, y;
}v[100005];

double det (double x1, double y1, double x2, double y2){
    return ((0-x1) * (y2-y1) - (x2-x1) * (0-y1)) / 2;
}
double dist (double x, double y){
    return x*x + y*y;
}

int main()
{
    int n, i;
    double ans=0, maxx=0;
    fin >> n;
    for (i=1; i<=n; i++)
        fin >> v[i].x >> v[i].y;
    v[n+1] = v[1];
    for (i=1; i<=n; i++)
        ans += det (v[i].x, v[i].y, v[i+1].x, v[i+1].y);
    if (ans < 0) ans = -ans;
    fout << std::setprecision(7) << fixed;
    cout << std::setprecision(12) << fixed;
    fout << ans << "\n";
    for (i=1; i<=n; i++){
        if (maxx < dist(v[i].x, v[i].y))
            maxx = dist(v[i].x, v[i].y);
    }
    for (i=1; i<=n; i++){
        //cout << maxx << " " << dist (v[i].x, v[i].y) << "\n";
        if (-0.0000001 < maxx - dist(v[i].x, v[i].y) and maxx - dist(v[i].x, v[i].y) < 0.0000001)
            fout << v[i].x << " " << v[i].y << "\n";
    }
    return 0;
}