Cod sursa(job #1404680)

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

using namespace std;

int n;
double x, y, x1, y1, 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);
   x1 = x;
   y1 = 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 * y1 - x1 * newY;
   printf("%.5lf\n", S/2);

   return 0;
}