标签:end iss rom its esc otto 三角形 div sea
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
#pragma comment(linker, "/STACK:1024000000,1024000000") #include<iostream> #include<cstdio> #include<cmath> #include<string> #include<queue> #include<algorithm> #include<stack> #include<cstring> #include<vector> #include<list> #include<bitset> #include<set> #include<map> #include<time.h> using namespace std; #define LL long long #define pi (4*atan(1.0)) #define eps 1e-8 #define bug(x) cout<<"bug"<<x<<endl; const int N=1e5+10,M=1e6+10,inf=1e9+10; const LL INF=1e18+10,mod=1e9+7; struct Point { double x, y ; } p[N]; int n ; double Area( Point p0, Point p1, Point p2 )// 求三角形面积公式 { double area = 0 ; area = p0.x * p1.y + p1.x * p2.y + p2.x * p0.y - p1.x * p0.y - p2.x * p1.y - p0.x * p2.y; return area / 2 ; //另外在求解的过程中,不需要考虑点的输入顺序是顺时针还是逆时针,相除后就抵消了。 } double xjhz() { double sum_area = 0 ; for ( int i = 2 ; i < n ; i++ ) { double area = Area(p[0],p[i-1],p[i]) ; sum_area += area ; } return sum_area; } int main () { while(~scanf ( "%d", &n ) ) { if(!n)break; for(int i=0; i<n; i++) scanf ( "%lf%lf", &p[i].x, &p[i].y ); printf("%.1f\n",xjhz()) ; } return 0 ; }
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 36553 Accepted Submission(s): 18889
标签:end iss rom its esc otto 三角形 div sea
原文地址:http://www.cnblogs.com/jhz033/p/7428193.html