Cod sursa(job #2130222)
Utilizator | Data | 13 februarie 2018 15:46:40 | |
---|---|---|---|
Problema | Aria | Scor | 70 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.58 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(6) << s;
return 0;
}