Cod sursa(job #1233975)

Utilizator afkidStancioiu Nicu Razvan afkid Data 26 septembrie 2014 15:27:38
Problema Aria Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.6 kb
#include <cstdio>

using namespace std;

const char Input[]="aria.in";
const char Output[]="aria.out";

int n;
double t,x1,x2,y1,y2;


inline double abs(double a)
{
    return ((a>=0)?a:-a);
}

int main()
{
    double x3,y3;
    freopen(Input,"r",stdin);
    freopen(Output,"w",stdout);
    scanf("%d",&n);
    scanf("%lf %lf",&x1,&y1);
    x3=x1;
    y3=y1;
    --n;
    t=0;
    for(;n;--n)
    {
        scanf("%lf %lf",&x2,&y2);
        t+=x1*y2-y1*x2;
        x1=x2;
        y1=y2;
    }
    t+=x1*y3-x3*y1;
    t*=0.5;
    printf("%.7lf\n",abs(t));
    return 0;
}