Cod sursa(job #2122551)

Utilizator ZenoTeodor Anitoaei Zeno Data 5 februarie 2018 11:30:17
Problema Aria Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.61 kb
#include <bits/stdc++.h>
#define NMAX 100001

using namespace std;

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

struct point{
    double x, y;
};

int n;
point S, A, B;
double aria;

double det(point A, point B, point C) {
    return (A.x * B.y + B.x * C.y + C.x * A.y - B.y * C.x - C.y * A.x - A.y * B.x) / 2;
}

int main()
{
    fin >> n;
    fin >> S.x >> S.y;
    fin >> A.x >> A.y;
    for(int i = 3; i <= n; i++) {
        fin >> B.x >> B.y;
        aria += det(S, A, B);
        A = B;
    }
    fout << fixed;
    fout << setprecision(5) << aria << '\n';
    return 0;
}