Pagini recente » Cod sursa (job #219977) | Cod sursa (job #2543132) | Cod sursa (job #40292) | Monitorul de evaluare | Cod sursa (job #2304100)
#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;
long 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);
g << fixed << setprecision (5) << 0.5 * o * mod (s) << '\n';
return 0;
}