Cod sursa(job #2060313)

Utilizator AlexandruLuchianov1Alex Luchianov AlexandruLuchianov1 Data 8 noiembrie 2017 08:13:42
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.76 kb
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>

using namespace std;
ifstream in ("aria.in");
ofstream out ("aria.out");
int const nmax = 100000;
struct point{
  long double x;
  long double y;
};
long double det3(point a , point b ,point c){
  long double splus =  a.x * b.y + a.y * c.x + b.x * c.y;
  long double sminus = a.x * c.y + a.y * b.x + b.y * c.x;
  return (splus - sminus) * 0.5;
}
int main()
{
  int n ;
  in>>n;
  point last ,p ,first ,a;
  in>>first.x>>first.y;
  last = first;
  p.x = p.y = 0;
  long double sum = 0;
  for(int i = 2 ; i <= n ;i++){
    in>>a.x>>a.y;
    sum += det3(p , last , a);
    last = a;
  }
  sum += det3(p , last , first);
  out<<setprecision(6)<<fixed<<sum;
  return 0;
}