Pagini recente » Istoria paginii runda/stefan-georgian1/clasament | Istoria paginii runda/cerc_info_avram_3/clasament | Istoria paginii runda/cni_pn | Istoria paginii calibrare-limite-de-timp | Cod sursa (job #2018389)
#include<fstream>
#include<cmath>
#include<iostream>
#include<iomanip>
#define x first
#define y second
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
int n;
long double mx,my,a;
typedef pair<long double,long double> per;
per x[100005];
long double arie(per a,per b,per c)
{
return (a.x*b.y+b.x*c.y+c.x*a.y-b.y*c.x-c.y*a.x-a.y*b.x);
}
int main()
{
fin>>n;
for(int i=1;i<=n;i++)
fin>>x[i].x>>x[i].y;
mx=x[1].x;
my=x[1].y;
// cout<<arie(make_pair(0,0),make_pair(4,0),make_pair(0,4))/2<<'\n';
for(int i=3;i<=n;i++)
{
a+=arie(x[i],x[i-1],make_pair(mx,my))/2;
// cout<<arie(x[i],x[i-1],make_pair(mx,my))<<'\n';
}
fout<<fixed<<setprecision(9)<<fabs(a);
}