Cod sursa(job #2530384)

Utilizator andreiomd1Onut Andrei andreiomd1 Data 24 ianuarie 2020 18:47:28
Problema Aria Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.02 kb
#include <bits/stdc++.h>

using namespace std;

ifstream f("aria.in");
ofstream g("aria.out");

typedef pair < long double, long double > Point;

const int NMAX = 1e5 + 5;
const long double HALF = 0.500000, UNIT = 1.000000;

int N;

Point A[NMAX];

long double ans;

static inline long double Det2 (Point A, Point B)
{
    return (UNIT * A.first * B.second) - (UNIT * A.second * B.first);
}

static inline void Read ()
{
    f.tie(NULL);

    f >> N;

    for(int i = 1; i <= N; ++i)
        f >> A[i].first >> A[i].second;

    return;
}

static inline long double my_abs (long double X)
{
    if(X < 0)
        return -X;

    return X;
}

static inline void Compute ()
{
    A[N + 1] = A[1];

    for(int i = 1; i <= N; ++i)
    {
        long double Area = Det2(A[i], A[i + 1]);

        ans += Area;
    }

    ans = my_abs(ans);

    ans *= HALF;

    return;
}

int main()
{
    Read();

    Compute();

    g << setprecision(6) << fixed << ans << '\n';

    return 0;
}