Cod sursa(job #2573002)
| Utilizator | Data | 5 martie 2020 15:21:27 | |
|---|---|---|---|
| Problema | Aria | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.55 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
#define x first
#define y second
double cp(pair<double, double> a, pair<double, double> b) {
return a.x * b.y - b.x * a.y;
}
int main() {
int n; fin >> n;
vector<pair<double, double>> pts(n + 1);
for (int i = 0; i < n; i++)
fin >> pts[i].x >> pts[i].y;
pts[n] = pts[0];
double area = 0;
for (int i = 1; i <= n; i++)
area += cp(pts[i - 1], pts[i]);
fout << area / 2 << '\n';
fout.close();
return 0;
}
