Cod sursa(job #1918380)

Utilizator eu3neuomManghiuc Teodor-Florin eu3neuom Data 9 martie 2017 15:13:50
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.62 kb
#include <bits/stdc++.h>

using namespace std;

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

typedef long double ld;

const int NMax = 1e5 + 5;

pair < ld, ld > v[NMax];

int main() {
    ios::sync_with_stdio(false);

    ld n;
    fin >> n;

    for(int i = 1; i <= n; i++) {
        ld a, b;
        fin >> a >> b;

        v[i] = {a, b};
    }
    v[(int)n + 1] = v[1];

    ld ans = 0;
    for(int i = 1; i <= n; i++) {
        ans += (v[i].first * v[i + 1].second - v[i].second * v[i + 1].first);
    }

    ans = ans / (ld)2;

    fout << fixed << setprecision(6) << ans;
    return 0;
}