Pagini recente » Cod sursa (job #2615241) | Cod sursa (job #2316742) | Cod sursa (job #43758) | Cod sursa (job #2750649) | Cod sursa (job #890116)
Cod sursa(job #890116)
Utilizator |
Simoiu Robert SpiderMan |
Data |
24 februarie 2013 21:08:03 |
Problema |
Aria |
Scor |
Ascuns |
Compilator |
cpp |
Status |
done |
Runda |
|
Marime |
0.7 kb |
# include <algorithm>
# include <cstdio>
# include <cmath>
using namespace std;
# define x first
# define y second
typedef pair <double, double> PR;
const char *FIN = "aria.in", *FOU = "aria.out";
const int MAX = 300005;
int N;
PR vec[MAX];
inline double arie (PR *vec, int sz) {
double sol = 0;
vec[sz++] = vec[0];
for (int i = 0; i + 1 < sz; ++i)
sol += vec[i].x * vec[i + 1].y - vec[i + 1].x * vec[i].y;
return fabs (sol * 0.5);
}
int main (void) {
freopen (FIN, "r", stdin);
freopen (FOU, "w", stdout);
scanf ("%d", &N);
for (int i = 0; i < N; ++i)
scanf ("%lf %lf", &vec[i].x, &vec[i].y);
printf ("%lf\n", arie (vec, N));
}