Cod sursa(job #1775715)

Utilizator ducu34Albastroiu Radu Gabriel ducu34 Data 10 octombrie 2016 17:24:49
Problema Aria Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.97 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>

using namespace std;

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

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

struct pn
{
    long long x, y;
}punct, last;

vector<pn> puncte;

// Punctul de test este ( 0, 0 )

double aria(double x1, double x2, double y1, double y2)
{
    return x1*y2 - y1*x2;
}

int main()
{
    
    fin >> n;
    
    for(i=1;i<=n;i++)
    {
        fin >> x >> y;
        punct.x = x;
        punct.y = y;
        puncte.push_back(punct);
    }
    
    last.x = puncte[n-1].x;
    last.y = puncte[n-1].y;
    for (i=0;i<n;i++)
    {
        A += aria(last.x, puncte[i].x, last.y, puncte[i].y);
        last.x = puncte[i].x;
        last.y = puncte[i].y;
    }
    
    fout << A/2;
    
    return 0;
}