Pagini recente » Cod sursa (job #3198290) | Cod sursa (job #1067476) | Cod sursa (job #3200025) | Cod sursa (job #769778) | Cod sursa (job #3005647)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
long double area(long double x1, long double y1, long double x2, long double y2, long double x3, long double y3)
{
return ((y2 + y1) * (x1 - x2) + (y1 + y3) * (x3 - x1) - (y2 + y3) * (x3 - x2)) * 0.5;
}
int32_t main()
{
cin.tie(nullptr)->sync_with_stdio(false);
int n;
fin >> n;
vector<pair<long double, long double>> a(n + 1);
for (int i = 1; i <= n; ++i)
{
fin >> a[i].first >> a[i].second;
}
a.push_back(a[1]);
long double ans = 0;
for (int i = 1; i <= n; ++i)
{
ans += area(0, 0, a[i].first, a[i].second, a[i + 1].first, a[i + 1].second);
}
fout << fixed << setprecision(10) << abs(ans) << '\n';
}