Cod sursa(job #1921990)
Utilizator | Calin-Stefan Georgescu borscalin | Data | 10 martie 2017 15:35:31 |
---|---|---|---|
Problema | Aria | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.51 kb |
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
int main(){
int n,i;
long double a,b,x1,x2,y1,y2,s;
fin >> n;
fin >> a >> b;
x1 = a;
y1 = b;
s = 0;
for (i=2;i<=n;++i) {
fin >> x2 >> y2;
s += x1 * y2 - x2 * y1;
x1 = x2;
y1 = y2;
}
s += x2*b - a*y2;
s = fabs(s / 2.0);
fout << fixed << setprecision(20) << s;
return 0;
}