Cod sursa(job #1692541)

Utilizator daniel.grosuDaniel Grosu daniel.grosu Data 21 aprilie 2016 10:04:09
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.44 kb
// Template v2
#define pb push_back
#define mp make_pair
#define first x
#define second y
#define l(x) x<<1
#define r(x) x<<1 | 1
#define lsb(x) x & -x
#include<fstream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<string.h>
#include <bitset>
using namespace std;
  
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PKK;
// primes less than 100
const int PRIM[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
const int CMAX = 100069;
const int MOD = 1000000007;
const int NMAX = 50069;
const int LOGMAX = log2(50069)+2;
const int INF16 = 320000;
const int INF = 2*1e9 + 6661369;
const LL INF64 = LL(1e18);
const LD EPS = 1e-9, PI = acos(-1.0);
const int dx[]={-1,1,0,0};
const int dy[]={0,0,1,-1};

ifstream cin("aria.in");
ofstream cout("aria.out");

int n;
LD fx, fy, x1, a1, x2, y2, s;

void read()
{
    cin>>n;
    cin>>x2>>y2;
    fx=x2;
    fy=y2;
    for(int i=2; i<=n; ++i){
        cin>>x1>>a1;
        s+=(x1*y2 - x2*a1);
        //cout<<(x1*y2 - x2*a1)/2<<"\n";
        x2=x1, y2=a1;
    }
    cin>>x1>>a1;
    //cout<<x1<<" "<<a1<<"\n";
    s+=(fx*a1-fy*x1);
    s/=2;
    cout<<abs(s);
}
 
int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);
    cout<<setprecision(10)<<fixed;
    read();
    return 0;
}