Cod sursa(job #2712635)

Utilizator Fatu_SamuelFatu Samuel Fatu_Samuel Data 26 februarie 2021 10:32:49
Problema Aria Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.6 kb
#include <fstream>
#include <iomanip>

using namespace std;

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

int n;

int main()
{
    fin >> n;
 
    long double s = 0, x, y, oldX, oldY, firstX, firstY;;

    fin >> oldX >> oldY;

    firstX = oldX;
    firstY = oldY;

    for (int i = 2; i <= n; i++)
    {
        fin >> x >> y;

        s += (oldX * y - oldY * x);

        oldX = x;
        oldY = y;
    }

    s += (oldX * firstY - oldY * firstX);

    s /= 2.0;

    fout << fixed << setprecision(5) << s;

    fin.close();
    fout.close();
    return 0;
}