Cod sursa(job #2564189)

Utilizator Bulboaca_EugenBulboaca Alexandru Eugen Bulboaca_Eugen Data 1 martie 2020 18:58:52
Problema Aria Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.75 kb
#include <bits/stdc++.h>
using namespace std;

#define zero(x) (x & (-x))
#define ll long long

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

const int  MAXN = 1e5 + 3;
const double EPS = 1e-8;
const long double INF = 1e12;

struct punct{
    int x, y;
}v[MAXN];

long double arie_triunghi(punct a, punct b, punct c){
    return a.x * b.y + b.x * c.y + c.x * a.y - c.x * b.y - a.y * b.x - c.y * a.x;
}

int main(){
    int n; fin >> n;
    long double s = 0;

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

    for(int i = 1; i <= n; ++i)
        s += arie_triunghi({0, 0}, v[i], v[i + 1]);
    s = abs(s);

    fout << setprecision(5) << fixed << 0.5 * s;
    return 0;
}
///18.681542