Cod sursa(job #1802332)

Utilizator diac_paulPaul Diac diac_paul Data 10 noiembrie 2016 09:41:59
Problema Aria Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.74 kb
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
 
#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
using namespace std;
struct point {
    double x, y;
};
point points[100002];
 
double arie(point a, point b, point c) {
    return (double)(a.x * b.y + b.x * c.y + a.y * c.x - a.x * c.y - a.y *b.x - c.x*b.y);
}
int main()
{
    ifstream f("aria.in");
    ofstream g("aria.out");
 
    int n;
    double aria = 0;
    f >> n;
 
    for (int i = 0; i < n; i++) {
        f >> points[i].x >> points[i].y;
    }
    points[n]= points[0];
    for (int i = 1; i < n; i++) {
        aria += arie(points[0], points[i], points[i + 1]);
    }
g << fixed << setprecision(5) << aria / 2;
return 0;
}