Cod sursa(job #2569945)

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

using namespace std;

#define x first
#define y second

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++)
    {
        int 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);

    rez /= 2;

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