Cod sursa(job #2363958)
Utilizator | Data | 3 martie 2019 19:29:58 | |
---|---|---|---|
Problema | Aria | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.6 kb |
#include <fstream>
#include <iomanip>
#include <cmath>
using namespace std;
ifstream fi("aria.in");
ofstream fo("aria.out");
const int NMAX=1e5+5;
struct punct {
long double x,y;
};
int n;
long double arie;
punct V[NMAX];
int main()
{
fi>>n;
for(int i=1;i<=n;i++)
{
fi>>V[i].x>>V[i].y;
V[i].x+=1000001.0;
V[i].y+=1000001.0;
}
V[n+1]=V[1];
for(int i=1;i<=n;i++)
arie+=(V[i+1].x-V[i].x)*(V[i+1].y+V[i].y);
if(arie<0) arie=-arie;
fo<<fixed<<setprecision(6)<<arie/2;
fi.close();
fo.close();
return 0;
}