Cod sursa(job #2364312)

Utilizator Anastasia11Susciuc Anastasia Anastasia11 Data 3 martie 2019 23:29:17
Problema Aria Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.58 kb
#include <iostream>
#include <fstream>
#include <iomanip>
#define x first
#define y second
#define Nmax 100005

using namespace std;

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

int n;
pair <long double, long double> v[Nmax];
long double S;

int main()
{
    f >> n;
    for (int i = 1; i <= n; i++)
    {
        long double a, b;
        f >> a >> b;
        v[i]={a, b};
    }
    v[n+1]=v[1];

    for(int i = 1; i <= n; i++)
    {
        S += v[i].x*v[i+1].y-v[i].y*v[i+1].x;
    }
    S/=2;
    g << fixed << setprecision(6) << S;

    return 0;
}