Cod sursa(job #3226026)

Utilizator Mihai_999Diaconeasa Mihai Mihai_999 Data 19 aprilie 2024 17:44:22
Problema Aria Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.57 kb
#include <iostream>
#include <fstream>
#include <iomanip>
#define nl '\n'

using namespace std;

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


int main()
{
    int N;
    long double x1, y1, x2, y2, x3, y3, A = 0;
    fin >> N >> x1 >> y1;
    x2 = x1;
    y2 = y1;
    while (--N)
    {
        fin >> x3 >> y3;
        A += x2*y3-x3*y2;
        x2 = x3;
        y2 = y3;
    }
    A += x2 * y1 - x1 * y2;
    A/=2;
    if (A < 0)
        A = -A;
    fout << fixed << setprecision(6) << A;
    fin.close();
    fout.close();
    return 0;
}