Pagini recente » Cod sursa (job #3283522) | Istoria paginii clasament-arhiva-monthly | Cod sursa (job #469711) | Cod sursa (job #2506373) | Cod sursa (job #1786701)
#include <cmath>
#include <fstream>
#include <iomanip>
#include <vector>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
struct Point {
double x, y;
Point(double x, double y) {
this->x = x;
this->y = y;
};
};
int N;
vector<Point> points;
void read() {
fin >> N;
for(int i = 0; i < N; ++i) {
double x, y;
fin >> x >> y;
points.emplace_back(x, y);
}
}
void solve() {
double solution = 0;
points.emplace_back(points[0].x, points[0].y);
for(int i = 0; i < N; ++i) {
solution += (points[i].x * points[i + 1].y - points[i + 1].x * points[i].y);
}
fout << fixed << setprecision(5) << fabs(solution / 2.0);
}
int main() {
read();
solve();
return 0;
}