Cod sursa(job #2749093)

Utilizator richardbaczur1Baczur Richard richardbaczur1 Data 4 mai 2021 22:31:00
Problema Aria Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.91 kb
#include <cmath>

#include <fstream>

#include <iomanip>

#include <vector>



using namespace std;



ifstream fin("aria.in");

ofstream fout("aria.out");



struct Point
{

    double x, y;

    Point(double x, double y)
    {

        this->x = x;

        this->y = y;

    };

};



int N;

vector<Point> points;



void read()
{

    fin >> N;

    for(int i = 0; i < N; ++i)
    {

        double x, y;

        fin >> x >> y;

        points.emplace_back(x, y);

    }

}



void solve()
{

    double solution = 0;



    points.emplace_back(points[0].x, points[0].y);

    for(int i = 0; i < N; ++i)
    {

        solution += (points[i].x * points[i + 1].y - points[i + 1].x * points[i].y);

    }



    fout << fixed << setprecision(5) << fabs(solution / 2.0);

}



int main()
{

    read();

    solve();

    return 0;

}