Cod sursa(job #2061130)

Utilizator CammieCamelia Lazar Cammie Data 8 noiembrie 2017 22:26:39
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.77 kb
#include <fstream>
#include <iomanip>

using namespace std;

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

struct punct{
    long double x, y;
};

inline long double det(punct p1, punct p2, punct p3) {
    return (p1.x * p2.y + p2.x * p3.y + p3.x * p1.y - (p3.x * p2.y + p1.x * p3.y + p2.x * p1.y));
}

inline void Read() {
    long double s = 0;
    int n;

    punct start, ante, curent;

    fin >> n;
    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) /(long double)2;
        ante = curent;
    }

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

int main () {
    Read();

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