Cod sursa(job #1775732)

Utilizator ducu34Albastroiu Radu Gabriel ducu34 Data 10 octombrie 2016 17:39:26
Problema Aria Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.82 kb
//
//  main.cpp
//  Aria
//
//  Created by Albastroiu Radu on 10/10/16.
//  Copyright © 2016 Albastroiu Radu. All rights reserved.
//

#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <cmath>

using namespace std;

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

long long i, n;
long double h, m, x, y, A;

struct pn
{
    long double x, y;
}punct, first;

// Punctul de test este ( 0, 0 )

int main()
{
    
    fin >> n;
    
    fin >> x >> y;
    punct.x = first.x = x;
    punct.y = first.y = y;
    for(i=2;i<=n;i++)
    {
        fin >> x >> y;
        A += 0.5 * (punct.x * y - x * punct.y);
        punct.x = x;
        punct.y = y;
    }
    
    A += 0.5 * (punct.x * first.y - first.x * punct.y);
    
    fout << A;
    
    return 0;
}