Pagini recente » Cod sursa (job #1906471) | Cod sursa (job #2879262) | Cod sursa (job #243305) | Cod sursa (job #337073) | Cod sursa (job #2448527)
#include <cstdio>
using namespace std;
FILE *f = fopen("aria.in","r");
FILE *g = fopen("aria.out","w");
long long det(int ax,int ay,int bx,int by,int cx,int cy){
return 1LL * ax * (by - cy) + 1LL * bx * (cy - ay) + 1LL * cx * (ay - by);
}
int main(){
long long arie = 0;
int n;
int x[21];
int y[21];
fscanf(f,"%d",&n);
for(int i = 1;i <= n;i++){
fscanf(f,"%d %d",&x[i],&y[i]);
if(i > 1)arie += det(0,0,x[i - 1],y[i - 1],x[i],y[i]);
}
arie += det(0,0,x[n],y[n],x[1],y[1]);
fprintf(g,"%.5f",(double)((arie < 0 ? -arie:arie) / 2));
fclose(f);
fclose(g);
return 0;
}