Cod sursa(job #2495027)

Utilizator SochuDarabaneanu Liviu Eugen Sochu Data 18 noiembrie 2019 19:43:50
Problema Aria Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.55 kb
#include <bits/stdc++.h>
#define NMAX 100005

using namespace std;

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

int n;

struct Point
{
    long double x , y;
}a[NMAX];

double Aria(Point a , Point b)
{
    return (a.x * b.y - a.y * b.x) / 2;
}

int main()
{
    int i;

    f >> n;

    for(i = 1 ; i <= n ; i++)
        f >> a[i].x >> a[i].y;

    long double ans = 0;

    a[n + 1] = a[1];

    for(i = 1 ; i <= n ; i++)
        ans += Aria(a[i] , a[i + 1]);

    g << setprecision(5) << fixed << ans;

    return 0;
}