Mai intai trebuie sa te autentifici.
Cod sursa(job #1826968)
| Utilizator | Data | 11 decembrie 2016 11:20:14 | |
|---|---|---|---|
| Problema | Aria | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.72 kb |
#include <fstream>
#include <cmath>
#include <iomanip>
using namespace std;
ifstream f("aria.in");
ofstream g("aria.out");
struct point
{
long double x,y;
}v[100001];
long double area(point a, point b, point c)
{
a.x -= c.x;
b.x -= c.x;
a.y -= c.y;
b.y -= c.y;
return fabs((long double)(a.x * b.y - b.x * a.y) / 2);
}
long double Aria(int n, point p[])
{
long double area_tot = 0;
for (int i = 2; i < n; i++)
{
area_tot += area(p[1], p[i], p[i+1]);
}
return area_tot;
}
int main()
{
int n;
f >> n;
for(int i = 1 ; i <= n ; ++i)
f >> v[i].x >> v[i].y;
g << fixed << setprecision(6) << Aria(n,v);
return 0;
}
