Cod sursa(job #2427100)

Utilizator mihnea.anghelMihnea Anghel mihnea.anghel Data 30 mai 2019 20:32:01
Problema Aria Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.54 kb
#include <fstream>
#define x first
#define y second
#include <iomanip>

using namespace std;
ifstream in ( "aria.in" );
ofstream out( "aria.out" );
pair < int, int > v[1000001];
long long n, i, sol;

long long arie ( pair < int, int > a, pair < int, int > b, pair < int, int > c ){
    return (b.x-a.x) * (c.y-a.y) - (c.x-a.x)*(b.y-a.y);
}

int main() {
    in>>n;
    for ( i=1; i <= n; i++ ) in >> v[i].x >> v[i].y;
    for ( i=1; i < n; i++ )
        sol += arie ( v[n], v[i], v[i+1] );
    out << setprecision(7) << fixed << sol/2;
    return 0;
}