Area

http://poj.org/problem?id=1265

 1 #include<cstdio>
 2 #include<istream>
 3 #include<algorithm>
 4 #include<cmath>
 5 int n;
 6 using namespace std;
 7 const int maxn=100;
 8 const double pi=acos(-1.0);
 9 int gcd(int a,int b)
10 {
11     return b==0?a:gcd(b,a%b);
12 }
13 struct Point  //点的定义
14 {
15     double x,y;
16     Point() {}
17     Point (double a,double b):x(a),y(b) {}
18 };
19 Point a[maxn],b[maxn];
20 double del(const Point &a,const Point &b)
21 {
22     return(a.x*b.y-a.y*b.x);
23 }
24 int main()
25 {
26     int t,c=0;
27 
28     scanf("%d",&t);
29     while(t--)
30     {
31         c++;
32         scanf("%d",&n);
33         int xx=0,yy=0,x,y,num=0;
34         for(int i=0; i<n; i++){
35             scanf("%d%d",&x,&y);
36             num+=gcd(abs(x),abs(y));
37             b[i+1].x=xx+x;
38             b[i+1].y=yy+y;
39             xx=b[i+1].x;
40             yy=b[i+1].y;
41         }
42         double sum=0;
43         b[0].x=0;
44         b[0].y=0;
45         for(int i=0; i<n; i++)
46           sum+=del(b[i],b[i+1]);
47         printf("Scenario #%d:\n",c);
48         printf("%d %d %.1lf\n",int(sum/2.0)+1-(num/2),num,sum/2);
49         printf("\n");
50     }
51 }
View Code

 

posted @ 2013-07-29 10:52  null1019  阅读(207)  评论(0编辑  收藏  举报