Mai intai trebuie sa te autentifici.

Cod sursa(job #919933)

Utilizator lucian666Vasilut Lucian lucian666 Data 19 martie 2013 22:13:20
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.98 kb



#include<fstream>
#include<utility>
#include<iomanip>


#define NN 100009
#define f first
#define s second
#define MKT make_pair


using namespace std;
ofstream out("aria.out");


int n ;
double H;

pair< double , double >v[NN];


void read();
void arie();
void wrs();

int main()
{
    read();
    arie();
    wrs();


    return 0;
}


void read()
{
    ifstream in("aria.in");

    in >> n ;
    for( int i = 1; i<=n ; i++)
    {
        double x , y;
        in >> x >> y;
        v[i] = MKT ( x , y );
    }
}

void arie()
{
    v[n+1] = MKT ( v[1].f , v[1].s ); // inchid figura

    for( int i=1 ; i<=n ; i++)
    {
        double X1 , X2 , Y1 , Y2;

        X1 = v[i].f - v[0].f;
        X2 = v[i+1].f - v[0].f;

        Y1 = v[i].s - v[0].s;
        Y2 = v[i+1].s - v[0].s;

        H+=( 1LL * ( X1 * Y2 ) - 1LL * ( X2 * Y1 ) );
    }
}

void wrs()
{

    setprecision(5);
    out << fixed <<  (  H/2 ) << '\n';
}