Pagini recente » Cod sursa (job #202300) | Rating Qwerty Dvorak (QwertyDvorak) | Statisticile problemei Joc6 | Sedinta 2007-11-28 | Cod sursa (job #1786687)
#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;
double solution, x, y;
vector<Point> points;
void read() {
fin >> N;
for(int i = 0; i < N; ++i) {
fin >> x >> y;
points.emplace_back(Point(x, y));
}
}
void solve() {
points.emplace_back(Point(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;
}