Cod sursa(job #1676327)

Utilizator GinguIonutGinguIonut GinguIonut Data 5 aprilie 2016 20:31:22
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.68 kb
#include <fstream>
#include <cmath>
#include <iomanip>

#define nMax 100003
#define pii pair<double, double>
#define mkp make_pair
#define x first
#define y second
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
int n;
pii Pct[nMax];
void read()
{
    double a, b;
    fin>>n;

    for(int i=1;i<=n;i++)
    {
        fin>>a>>b;
        Pct[i]=mkp(a, b);
    }
    Pct[n+1]=Pct[1];
}
void solve()
{
    double Arie=0;

    for(int i=1;i<=n;i++)
        Arie=Arie+1LL * (1LL * Pct[i].x * Pct[i+1].y - 1LL * Pct[i].y * Pct[i+1].x);

    fout<<fixed<<setprecision(5)<<fabs(Arie/2);
}
int main()
{
    read();
    solve();
    return 0;
}