Cod sursa(job #2016976)

Utilizator workwork work work Data 30 august 2017 23:45:59
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.55 kb
#include <bits/stdc++.h>

#define f first
#define sd second

using namespace std;

ifstream F("aria.in");
ofstream G("aria.out");

int n;
double s;
pair<double, double> p[100005];

double det(pair<double, double> fst, pair<double, double> snd)
{
    return (fst.f*snd.sd - fst.sd*snd.f)/2;
}

int main()
{
    F >> n;
    for(int i = 1; i <= n; ++ i) F>>p[i].f>>p[i].sd;
    p[0].f = p[n].f;
    p[0].sd = p[n].sd;
    for(int i = 1; i <= n; ++ i)
        s+=det(p[i-1], p[i]);
    G << setprecision(5)<<fixed<<s;
    return 0;
}