Pagini recente » Cod sursa (job #2066282) | Cod sursa (job #2199938) | Cod sursa (job #186367) | Cod sursa (job #2819110) | Cod sursa (job #963601)
Cod sursa(job #963601)
#include <fstream>
#include <vector>
#include <iomanip>
using namespace std;
#define x first
#define y second
#define add push_back
typedef double ld;
typedef pair <ld, ld> punct;
typedef vector <punct> poligon;
poligon P;
int n;
ld abs(ld x) {
return ((x > -x) ? x : -x);
}
ld min(ld x, ld y) {
return ((x > y) ? y : x);
}
ld arie(punct A, punct B, punct C) {
return (B.x - A.x) * (C.y - A.y) - (C.x - A.x) * (B.y - A.y);
}
ifstream fin ("aria.in");
ofstream fout ("aria.out");
int main() {
fin >> n;
punct P0;
P0.y = P0.x = 1000005;
for (int i = 0; i < n; ++i) {
punct p;
fin >> p.x >> p.y;
P0.y = min(P0.y, p.y);
P0.x = min(P0.x, p.x);
P.add(p);
}
fin.close();
ld A = 0;
for (int i = 0; i < n; ++i)
A += arie(P0, P[i], P[(i + 1) % n]);
fout << fixed << setprecision(6) << abs(A / 2);
fout.close();
return 0;
}