Cod sursa(job #2734990)
| Utilizator | Data | 1 aprilie 2021 18:23:48 | |
|---|---|---|---|
| Problema | Aria | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.58 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
struct point
{
double x,y;
} v[100005];
int n;
double ans;
double aria(point a, point b, point c)
{
a.x-=c.x;
b.x-=c.x;
a.y-=c.y;
b.y-=c.y;
return a.x*b.y-a.y*b.x;
}
int main()
{
ios_base::sync_with_stdio(false);
fin.tie(0);
fout.tie(0);
fin>>n;
for(int i=1;i<=n;i++)
fin>>v[i].x>>v[i].y;
for(int i=2;i+1<=n;i++)
ans+=aria(v[i],v[i+1],v[i+2]);
ans=abs(ans);
fout<<ans;
return 0;
}
