Cod sursa(job #2060833)

Utilizator FunnyStockyMihnea Andreescu FunnyStocky Data 8 noiembrie 2017 18:58:53
Problema Aria Scor 50
Compilator cpp Status done
Runda Arhiva educationala Marime 0.72 kb
#include <fstream>
#include <iomanip>
#include <math.h>
using namespace std;
ifstream cin("aria.in");
ofstream cout("aria.out");
#define ll long double
struct fint
{
    ll x,y;
};
ll dist(ll x1,ll y1,ll x2,ll y2)
{
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
ll area(ll x1,ll y1,ll x2,ll y2,ll x3,ll y3)
{
    ll a=dist(x1,y1,x2,y2),b=dist(x2,y2,x3,y3),c=dist(x1,y1,x3,y3),p=(a+b+c)/2;
    return sqrt(p*(p-a)*(p-b)*(p-c));
}
fint v[100005];
ll sum=0;
int n;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>v[i].x>>v[i].y;
    for(int st=2;st<n;st++)
        sum+=area(v[1].x,v[1].y,v[st].x,v[st].y,v[st+1].x,v[st+1].y);
    cout<<fixed<<setprecision(5)<<sum;
    return 0;
}