Cod sursa(job #2154737)

Utilizator CammieCamelia Lazar Cammie Data 7 martie 2018 11:33:47
Problema Aria Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.82 kb
#include <fstream>
#include <iomanip>

using namespace std;

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

struct punct{
    int x, y;
};

inline double det(punct c1, punct c2, punct c3) {
    int delta = c1.x * c2.y + c2.x * c3.y + c1.y * c3.x - c2.y * c3.x - c1.x * c3.y - c2.x * c1.y;
    if (delta < 0) delta *= -1;

    double sol = delta / 2.;

    return sol;
}

inline void Read() {
    int N;
    punct start, ante, curent;

    fin >> N; double s = 0;

    fin >> start.x >> start.y;
    fin >> ante.x >> ante.y;

    for (int i = 3; i <= N; i++) {
        fin >> curent.x >> curent.y;

        s += det(start, ante, curent);

        ante = curent;
    }

    fout << fixed << setprecision(5) << s;
}

int main () {
    Read();

    fin.close(); fout.close(); return 0;
}