Cod sursa(job #1259668)

Utilizator laurageorgescuLaura Georgescu laurageorgescu Data 10 noiembrie 2014 12:51:35
Problema Aria Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.57 kb
#include<fstream>
#include<iomanip>

using namespace std;

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

const int nmax = 100001;
float x[ nmax ], y[ nmax ];

int main() {
    int n;
    float ans;
    fin >> n;
    for( int i = 0; i < n; ++ i ) {
        fin >> x[ i ] >> y[ i ];
    }
    ans = 0;
    x[ n ] = x[ 0 ];
    y[ n ] = y[ 0 ];
    for( int i = 0; i < n; ++ i ) {
        ans += ( x[ i ] * y[ i + 1 ] - x[ i + 1 ] * y[ i ] );
    }
    fout << setprecision( 5 ) << fixed;
    fout << 0.5 * ans << "\n";
    fin.close();
    fout.close();
    return 0;
}