Cod sursa(job #2569958)

Utilizator XXMihaiXX969Gherghinescu Mihai Andrei XXMihaiXX969 Data 4 martie 2020 14:27:12
Problema Aria Scor 0
Compilator cpp-64 Status done
Runda r3capitusulare Marime 0.68 kb
#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define double long double

ifstream in("aria.in");
ofstream out("aria.out");

vector < pair <double,double> > v;

int main()
{
    int n;
    in >> n;

    for(int i = 0; i < n; i++)
    {
        long double a, b;
        in >> a >> b;

        v.push_back({a * 1.0,b * 1.0});
    }

    v.push_back({v.front().x,v.front().y});

    double rez = 0;

    for(int i = 0; i < v.size() - 1; i++)
        rez += (v[i].x * v[i + 1].y - v[i + 1].x * v[i].y);

        if(rez < 0)
            rez *= -1;

    rez /= 2.0;

    out << fixed << setprecision(9) << rez;
    return 0;
}