Cod sursa(job #1146383)

Utilizator SilverGSilver Gains SilverG Data 18 martie 2014 22:09:01
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.62 kb
/*
Keep It Simple!
*/

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include<stdio.h>
#define MaxN 100001

int N;
double S;

struct Point { double x, y; }Points[MaxN];

double Abs(double a) { return (a) < 0 ? (-a) : (a); }

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

	scanf("%d", &N);
	
	for (int i = 1; i <= N; i++)
		scanf("%lf%lf", &Points[i].x, &Points[i].y);
	Points[0] = Points[N];

	for (int i = 1; i <= N; i++)
		S = S+(Points[i - 1].x * Points[i].y) - (Points[i - 1].y * Points[i].x);

		S = Abs(S);
	S /= 2;
	printf("%.5lf", S);

	return 0;
}