Cod sursa(job #3291582)

Utilizator ImphinityComan Razvan Ioan Imphinity Data 5 aprilie 2025 09:56:45
Problema Aria Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.54 kb
#include <bits/stdc++.h>
#define cin in
#define cout out
using namespace std;

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

struct punct
{
    long double x, y;
};

long double arie(punct a, punct b)
{
    return ((a.x*b.y)-(a.y*b.x))/2;
}

int main()
{
    int n;
    punct nr, nr2, first;
    long double a=0;
    cin>>n>>nr.x>>nr.y>>nr2.x>>nr2.y;
    first=nr, a+=arie(nr, nr2);
    for(int i=2; i<n; i++)
    {
        nr=nr2;
        cin>>nr2.x>>nr2.y;
        a+=arie(nr,nr2);
    }
    a+=arie(nr2, first);
    cout<<fixed<<setprecision(5)<<a;
}