Cod sursa(job #1517110)

Utilizator XladhenianGrigorita Vlad-Stefan Xladhenian Data 3 noiembrie 2015 21:02:41
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.9 kb

#include <fstream>

using namespace std;

int n;

long double firstX;
long double firstY;

int main(void)
{
    fstream fin("aria.in",ios::in);
    fstream fout("aria.out",ios::out);

    long double result = 0.0f;

    fin >> n;
    if (n >= 3)
    {
        fin >> firstX >> firstY;

        long double tempX = firstX;
        long double tempY = firstY;
        n -= 1;
        while (n > 0)
        {
            long double newX;
            long double newY;
            fin >> newX >> newY;
            result += (tempX * newY - newX * tempY);
            tempX = newX;
            tempY = newY;
            n -= 1;
        }
        long double newX = firstX;
        long double newY = firstY;
        result += (tempX * newY - newX * tempY);
    }

    fout.precision(20);

    fout << (result * 0.5f) << endl;

    fin.close();
    fout.close();

    return 0;
}