Cod sursa(job #1759032)

Utilizator Burbon13Burbon13 Burbon13 Data 18 septembrie 2016 14:00:12
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.65 kb
#include <cstdio>
#include <iostream>
#define x first
#define y second

using namespace std;

const int nmx = 100002;

int n;
pair <double,double> v[nmx];

void citire()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
        scanf("%lf %lf", &v[i].x, &v[i].y);
}

void calcul()
{
    double t = 0;

    for(int i = 1; i < n; ++i)
        t += v[i].x * v[i+1].y - v[i+1].x * v[i].y;
    t += v[n].x * v[1].y - v[1].x * v[n].y;

    if(t < 0)
        t = -t;

    printf("%lf\n", t / 2);
}

int main()
{
    freopen("aria.in", "r", stdin);
    freopen("aria.out", "w", stdout);
    citire();
    calcul();
    return 0;
}