Cod sursa(job #2672350)

Utilizator tifui.alexandruTifui Ioan Alexandru tifui.alexandru Data 13 noiembrie 2020 18:42:17
Problema Aria Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.75 kb
#include <bits/stdc++.h>
#define ld long double
#define point pair <ld, ld>
#define x first
#define y second

using namespace std;

ld det(point p1, point p2, point p3) {
    return p1.x * p2.y + p2.x * p3.y + p3.x * p1.y -
           p1.y * p2.x - p2.y * p3.x - p3.y * p1.x;
}

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ifstream cin("aria.in");
    ofstream cout("aria.out");
    
    int n;
    cin >> n;
    vector < point > v(n);

    for (auto& it : v) 
        cin >> it.x >> it.y;

    v.emplace_back(v[0]);

    ld area = 0;    
    for (int i = 0; i < n; ++i) {
        area += det({0, 0}, v[i], v[i + 1]);
    }

    cout << fixed << setprecision(6) << 0.5 * abs(area) << '\n';

    return 0;
}