Cod sursa(job #1305258)
Utilizator | Data | 29 decembrie 2014 17:49:59 | |
---|---|---|---|
Problema | Aria | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.54 kb |
#include <fstream>
#include <cmath>
#include <iomanip>
#define nmax 100005
using namespace std;
ifstream f("aria.in");
ofstream g("aria.out");
int n,k;
double sol;
struct punct {int x;int y;};
punct p[nmax];
double det(const punct &a,const punct &b,const punct &c)
{return ((c.x-a.x)*(b.y-a.y)-(b.x-a.x)*(c.y-a.y))/2.0;
}
int main(){
int i,j;
f>>n;
for (i=1;i<=n;i++) f>>p[i].x>>p[i].y;
p[n+1]=p[1];
for (i=1;i<=n;i++) sol+=det(p[0],p[i],p[i+1]);
g<<setprecision(6)<<fixed<<abs(sol);
return 0;
}