Cod sursa(job #2946128)

Utilizator bogdan.schiopBogdan Schiop bogdan.schiop Data 24 noiembrie 2022 16:31:25
Problema Aria Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.5 kb
#include <iostream>
#include <fstream>
#include<cmath>

using namespace std;

ifstream fin("aria.in");
ofstream fout("aria.out");

int n;
long double x[100001],y[100001];

void citire()
{
    fin >> n;
    for(int i = 1; i <= n; i++)
        fin >> x[i] >> y[i];
}

int main()
{
    citire();
    long double s = 0;
    x[n+1] = x[1];
    y[n+1] = y[1];
    for(int i = 1; i <= n; i++)
    {
        s+= abs(x[i]*y[i+1] - x[i+1]*y[i]);
    }
    fout << s/2.0;
    return 0;
}