Cod sursa(job #1796194)

Utilizator andreey_047Andrei Maxim andreey_047 Data 3 noiembrie 2016 10:42:50
Problema Aria Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.75 kb
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

const int nmax = 100005; const LL inf = 1e18;

   ifstream f("aria.in");
   ofstream g("aria.out");

struct el{
 double x,y;
}a[nmax];
int N;
double sol;

inline long double Arie(int i,int j,int q){
 return ((a[j].x-a[i].x)*(a[q].y-a[i].y) - (a[j].y-a[i].y)*(a[q].x-a[i].x));
}
int main(){
//   #ifndef GLOBAL_JUDGE
//      freopen("txt.in","r",stdin);
//      freopen("txt.out","w",stdout);
//   #endif // GLOBAL_JUDGE

   int i;
   f >> N;
   for(i = 1; i <= N; ++i)
      f>> a[i].x >> a[i].y;
   f.close();
   for(i = 3; i <= N; ++i)
      sol+=Arie(1,i-1,i);
   sol/=2;
   g << fixed << setprecision(6)<< sol << '\n';

   g.close();
   return 0;
}