Cod sursa(job #1876018)

Utilizator cautionPopescu Teodor caution Data 11 februarie 2017 21:18:07
Problema Aria Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.44 kb
#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n;
	double x0, y0, x1, y1, x2, y2, s = 0;
	freopen("aria.in", "rt", stdin);
	freopen("aria.out", "wt", stdout);

	scanf("%d", &n);
	
	scanf("%lf%lf", &x0, &y0);
	x2 = x0; y2 = y0;
	for (int i = 1; i < n; ++i) {
		x1 = x2; y1 = y2;
		scanf("%lf%lf", &x2, &y2);
		s += x2 * y1 - x1 * y2;
	}
	s += x0 * y2 - x2 * y0;
	if (s < 0) s = -s;
	s /= 2;

	printf("%.5lf\n", s);

	return 0;
}