Cod sursa(job #2130220)
| Utilizator | Data | 13 februarie 2018 15:41:12 | |
|---|---|---|---|
| Problema | Aria | Scor | 70 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.56 kb |
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
ifstream f("aria.in");
ofstream g("aria.out");
struct punct
{
double x, y;
};
inline double det(punct A, punct B)
{
return A.x * B.y - A.y * B.x;
}
int main()
{
int n;
double s=0;
f >> n;
punct a, b, c;
f >> a.x >> a.y;
c = a;
for(int i = 0; i < n; i++)
{
f >> b.x >> b.y;
s += det(a, b);
a=b;
}
s+=det(b,c);
if(s<0)s=-s;
s/=2;
g<<fixed<<setprecision(5)<<s;
return 0;
}
