Cod sursa(job #1404701)

Utilizator c0rn1Goran Cornel c0rn1 Data 28 martie 2015 14:24:49
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.55 kb
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int n;
long double x, y, xprim, yprim, newX, newY, S;

int main()
{
   freopen("aria.in", "r", stdin);
   freopen("aria.out", "w", stdout);
   scanf("%d\n", &n);
   scanf("%Lf %Lf\n", &x, &y);
   xprim = x;
   yprim = y;
   for (int i = 2; i <= n; ++i){
      scanf("%Lf %Lf\n", &newX, &newY);
      S = S + x * newY - newX * y;
      x = newX;
      y = newY;
   }
   S = S + newX * yprim - xprim * newY;
   printf("%.5Lf\n", S/2);

   return 0;
}