Cod sursa(job #2399395)

Utilizator ezioconnorVlad - Gabriel Iftimescu ezioconnor Data 7 aprilie 2019 14:27:23
Problema Aria Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.49 kb
#include <bits/stdc++.h>

using namespace std;

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

struct vec
{
    long double x, y;
}v[100001];

int main()
{
    int n;
    long double s = 0;
    in >> n;
    for (int i = 1; i <= n; ++i)
        in >> v[i].x >> v[i].y;
    s = 0.5 * (v[n].x * v[1].y - v[n].y * v[1].x);
    for (int i = 1; i < n; ++i)
        s += 0.5 * (v[i + 1].y * v[i].x - v[i + 1].x * v[i].y);
    return out << fixed << setprecision(6) << s, 0;
}