Pagini recente » Cod sursa (job #1264) | Profil CostacheMihnea | Profil Pepelea_Flaviu | Cod sursa (job #334145) | Cod sursa (job #1217745)
#include <iostream>
#include <fstream>
#include <iomanip>
#define N 100001
// 1 x0 y0
// 1 x1 y1
// 1 x2 y2
template <typename T> struct point
{
T x,y;
point():x(0),y(0){}
point(T x, T y):x(x),y(y){}
};
point<long double> p[N];
template <typename T>
T area2(point<T> p0, point<T> p1, point<T> p2)
{
T ret = +p1.x*p2.y - p2.x*p1.y
-p0.x*p2.y - p2.x*p0.y
+p0.x*p1.y - p1.x*p0.y;
return ret;
}
int main ()
{
std::ifstream fin("aria.in");
std::ofstream fout("aria.out");
int n,x,y;
long double total=0;
fin>>n;
for(int i=0;i<n;i++)
{
fin>>p[i].x>>p[i].y;
}
p[n]=p[0];
point<long double> zero(0,0);
for(int i=0;i<n;i++)
{
long double area = area2(zero, p[i], p[i+1]);
total+=area/2.0;
}
fout<<std::setprecision(15)<<total;
return 0;
}