Cod sursa(job #3257470)

Utilizator MikeStrikeAgache Mihai MikeStrike Data 17 noiembrie 2024 19:50:32
Problema Aria Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.55 kb
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
using namespace std;

struct Point {
    long long x, y;
};

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

    int n;
    fin >> n;

    Point v[n + 1];
    long double a = 0.0;

 
    for (int i = 0; i < n; i++) {
        fin >> v[i].x >> v[i].y;
    }
    v[n] = v[0]; 


    for (int i = 0; i < n; i++) {
        a += (v[i].x * v[i + 1].y) - (v[i + 1].x * v[i].y);
    }


    fout << fixed << setprecision(5) << abs(a / 2.0) << "\n";

    return 0;
}