Cod sursa(job #3200367)

Utilizator Mihai_PopescuMihai Popescu Mihai_Popescu Data 4 februarie 2024 14:24:15
Problema Aria Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.57 kb
#include <fstream>
#include <iomanip>
using namespace std;

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

int main() {
    int n;
    fin >> n;
    double x1, y1;
    fin >> x1 >> y1;
    double x0 = x1, y0 = y1;

    double arie = 0;
    for (int i = 2; i <= n; ++i) {
        double x2, y2;
        fin >> x2 >> y2;

        arie += (x1 * y2 - x2 * y1) / 2.0;
        if (i == n) {
            arie += (x2 * y0 - x0 * y2) / 2.0;
        }
        x1 = x2;
        y1 = y2;
    }

    fout << setprecision(5) << fixed << arie;
    return 0;
}