Cod sursa(job #1922119)

Utilizator MoodyFaresFares Mohamad MoodyFares Data 10 martie 2017 16:03:37
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.59 kb
#include <cstdio>

using namespace std;
const int MAX_N = 100000;

struct Point {
  double x;
  double y;
};

Point v[5 + MAX_N];

int main() {
  freopen ("aria.in", "r", stdin);
  freopen ("aria.out", "w", stdout);

  int N;
  scanf ("%d", &N);
  double aria = 0;
  for (int i = 1; i <= N; ++i) {
    double x, y;
    scanf ("%lf%lf", &x, &y);
    v[i] = Point {x, y};
  }
  for (int i = 1; i <= N; ++i) {
    int next = i + 1;
    if (i == N)
      next = 1;
    aria += (v[i].x * v[next].y - v[next].x * v[i].y);
  }
  aria /= 2;
  printf ("%.5f", aria);
  return 0;
}