Cod sursa(job #3219581)

Utilizator UengineDavid Enachescu Uengine Data 31 martie 2024 17:58:20
Problema Aria Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.68 kb
#include <fstream>
#include <iomanip>
#include <cmath>

using namespace std;

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

struct pct{
    double x, y;
};

const int N = 1e5 + 5;
pct v[N];

double det(double x1, double y1, double x2, double y2){
    return x1 * y2 - x2 * y1;
}

int main()
{
    cin.tie(nullptr);
    int n;
    cin >> n;
    if(n < 3){
        cout << 0;
        return 0;
    }
    long double sum = 0;
    for(int i = 0; i < n; i++)
        cin >> v[i].x >> v[i].y;
    v[n] = v[0];
    for(int i = 0; i < n; i++)
        sum += det(v[i].x, v[i].y, v[i + 1].x, v[i + 1].y) / 2.0;
    cout << setprecision(5) << sum;
    return 0;
}