Pagini recente » Cod sursa (job #876704) | Cod sursa (job #886258) | Cod sursa (job #2161303) | Cod sursa (job #1348287) | Cod sursa (job #1812373)
#include <cstdio>
long long det(int ax, int ay, int bx, int by, int cx, int cy) {
return (long long)ax * by +
(long long)bx * cy +
(long long)cx * ay -
(long long)ax * cy -
(long long)bx * ay -
(long long)cx * by;
}
const int MAX_P = 100000;
int x[MAX_P], y[MAX_P];
int main() {
int n, j;
long long arie;
FILE *fin = fopen("aria.in", "r");
fscanf(fin, "%d", &n);
for(int i = 0; i < n; ++i)
fscanf(fin, "%d%d", &x[i], &y[i]);
fclose(fin);
arie = 0LL;
for(int i = 0; i < n; ++i) {
j = (i + 1) % n;
arie = arie + det(0, 0, x[i], y[i], x[j], y[j]);
}
FILE *fout = fopen("aria.out", "w");
if(arie < 0)
arie = -arie;
fprintf(fout, "%lld", arie / 2);
if(arie % 2 == 1)
fprintf(fout, ".5");
fclose(fout);
return 0;
}