Cod sursa(job #1369321)

Utilizator gabrielinelusGabriel-Robert Inelus gabrielinelus Data 2 martie 2015 23:43:13
Problema Aria Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.63 kb
#include <fstream>
#include <iomanip>

#define EPS 1000000

using namespace std;
double xs,ys,xc,yc,xa,ya,rez = 0;
int N;


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

    fin >> N;
    fin >> xs >> ys;
    xs += EPS;
    ys += EPS;
    xa = xs;
    ya = ys;
    for(int i = 2; i <= N; ++i){
        fin >> xc >> yc;
        xc += EPS;
        yc += EPS;
        rez += (ya + yc)*(xa - xc);
        xa = xc;
        ya = yc;
    }
    rez += (ya + ys)*(xa - xs);

    if(rez < 0)
        rez *= -1;
    fout << setprecision(6) << fixed;
    fout << rez / 2;
    return 0;
}