Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 36149 Accepted Submission(s):
18651
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<algorithm> using namespace std; typedef long long lol; lol n; double ans; struct Vector { double x,y; Vector(){} Vector(double xx,double yy){x=xx;y=yy;} Vector operator+(Vector b) { Vector s; s.x=x+b.x;s.y=y+b.y; return s; } Vector operator-(Vector b) { Vector s; s.x=x-b.x;s.y=y-b.y; return s; } double operator*(Vector b) { return x*b.y-y*b.x; } double operator^(Vector b) { return x*b.x+y*b.y; } }a,b,c; lol gi() { lol ans=0,f=1; char i=getchar(); while(i<‘0‘||i>‘9‘){if(i==‘-‘)f=-1;i=getchar();} while(i>=‘0‘&&i<=‘9‘){ans=ans*10+i-‘0‘;i=getchar();} return ans*f; } int main() { while(1) { n=gi(); if(n==0)break; ans=0; scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y); ans+=(b-a)*(c-a); for(lol i=4;i<=n;i++) { b=c; scanf("%lf%lf",&c.x,&c.y); ans+=(b-a)*(c-a); } ans/=2; printf("%.1lf\n",ans); } return 0; }
原文:http://www.cnblogs.com/huangdalaofighting/p/7258634.html