Cod sursa(job #2570494)

Utilizator NotTheBatmanBruce Wayne NotTheBatman Data 4 martie 2020 17:10:43
Problema Aria Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.65 kb
#include <fstream>
#include <cmath>
#include <iomanip>
using namespace std;

const int N = 1e5 + 5;

pair <double, double> points[N];
int n;

void Read ()
{
    ifstream fin ("aria.in");
    fin >> n;
    for (int i = 1; i <= n; i++)
        fin >> points[i].first >> points[i].second;
    long double surface = 0;
    points[n + 1] = points[1];
    for (int i = 1; i <= n; i++)
        surface += (points[i].first * points[i + 1].second - points[i].second * points[i + 1].first);
    ofstream fout ("aria.out");
    fout << setprecision(5) << fixed << (surface / 2.0) << "\n";
    fout.close();
}

int main()
{
    Read();
    return 0;
}