Pagini recente » Cod sursa (job #1766540) | Cod sursa (job #383902) | Cod sursa (job #2863919) | Cod sursa (job #369967) | Cod sursa (job #2253027)
#include <fstream>
#include <iomanip>
using namespace std;
long double abs(long double x)
{
return x > 0 ? x : -x;
}
int main()
{
int n;
double x[100002];
double y[100002];
long double cx = 0, cy = 0;
ifstream f("aria.in");
ofstream g("aria.out");
f >> n;
for(auto i=0; i<n; ++i)
{
f >> x[i] >> y[i];
cx += x[i];
cy += y[i];
}
x[n] = x[0];
y[n] = y[0];
cx = cx / ( long double)n;
cy = cy / ( long double)n;
long double s = 0;
for(auto i=0; i<n; ++i)
{
s += abs(cx * y[i] +
x[i+1] * cy +
x[i] * y[i+1] -
x[i+1] * y[i] -
cx * y[i+1] -
x[i] * cy);
}
s = s/(long double)2;
g << std::setprecision(6) << s;
return 0;
}