Pagini recente » Cod sursa (job #859319) | Cod sursa (job #1468613) | Cod sursa (job #1892786) | Cod sursa (job #2043449) | Cod sursa (job #2304097)
#include <fstream>
#include <iomanip>
using namespace std;
ifstream f ("aria.in");
ofstream g ("aria.out");
int const NM = 1e5;
double const o = 1;
pair <double , double> v [1 + NM];
int n;
double mod (double x){
return o * (x > 0 ? x : -x);
}
double area (double x , double y , double x1 , double y1){
return o * (y + y1) * (x1 - x);
}
int main()
{
f >> n;
double s = 0;
for(int i = 1 ; i <= n ; ++ i)
f >> v [i] . first >> v [i] . second ;
v [1 + n] . first = v [1] . first;
v [1 + n] . second = v [1] . second;
for(int i = 1 ; i <= n ; ++ i)
s += o * area (v [i] . first , v [i] . second , v [1 + i] . first , v [1 + i] . second);
s = (double)(s / 2);
g << fixed << setprecision (6) << mod (s) << '\n';
return 0;
}