Cod sursa(job #2146646)

Utilizator loo_k01Luca Silviu Catalin loo_k01 Data 28 februarie 2018 09:13:14
Problema Aria Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.73 kb
#include <bits/stdc++.h>

using namespace std;

ofstream fout("aria.out");
struct Dublu
{
    double x, y;
}a[100005];
int n;

void Read()
{
    ifstream fin("aria.in");
    fin >> n;
    for (int i = 1; i <= n; i++)
        fin >> a[i].x >> a[i].y;

    a[++n] = a[1]; /// inchid ciclul
    fin.close();
}

/**

    | 0  0  1| //origine
    | x1 y1 1| // punctul1
    | x2 y2 1| // punctul2

    y1 + x1*y2 + x2 - x2*y1 - x2 - y2 =          x1*y2 - x2*y1

*/

int main()
{
    long double sol = 0.0;

    Read();

    for (int i = 2; i <= n; i++)
        sol += (a[i - 1].x * a[i].y - a[i - 1].y * a[i].x); /// determinant

    fout << fixed << setprecision(7) << 0.5 * sol << "\n";

    return 0;
}