Pagini recente » Cod sursa (job #2415400) | Cod sursa (job #1487905) | Cod sursa (job #598336) | Cod sursa (job #3202013) | Cod sursa (job #1257611)
#include <fstream>
using namespace std;
long long areaTri(int x0, int y0, int x1, int y1) {
/*
| 1 0 0 |
| 1 x0 y0 |
| 1 x1 y1 |
*/
return (long long)x0 * y1 - (long long)x1 * y0;
}
int main() {
ifstream f("aria.in",ios::in);
ofstream g("aria.out",ios::out);
int n;
f >> n;
long long cnt = 0;
if(n > 1) {
int x0, y0;
f >> x0 >> y0;
int x0s,y0s,x1,y1, xt, yt;
x0s = x0, y0s = y0;
f >> x1 >> y1;
cnt += areaTri(x0, y0, x1, y1);
for(int i = 2; i < n; i++) {
f >> xt >> yt;
x0 = x1, y0 = y1, x1 = xt, y1 = yt;
cnt += areaTri(x0,y0,x1,y1);
}
cnt += areaTri(x1,y1,x0s,y0s);
}
g << cnt / 2.0 << endl;
return 0;
}