Cod sursa(job #3343095)

Utilizator Cristian_NegoitaCristian Negoita Cristian_Negoita Data 26 februarie 2026 14:26:04
Problema Aria Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.76 kb
#include <bits/stdc++.h>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
int n;
struct Point { long double x, y; };
vector<Point> points;

long double cross(Point O, Point A, Point B)
{
    return (A.x - O.x) * (B.y - O.y) - (A.y - O.y) * (B.x - O.x);
}

long double arie()
{
    long double A = 0;
    for(int i = 0; i < points.size(); i++)
    {
        Point P = points[i], Q = points[(i + 1) % points.size()];
        A += cross({0, 0}, P, Q) / 2;
    }
    return A;
}

int main()
{
    fin >> n;
    while(n--)
    {
        long double x, y;
        fin >> x >> y;
        points.push_back({x, y});
    }
    fout << fixed << setprecision(12) << arie();

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