# zoj1032 Area 2

1. //zoj1032 Area 2

2. //Accepted 1032 C++ 00:00.00 392K

3. #include <stdio.h>

4. #define MAXN 100

5.

6. struct point{ double x,y;};

7.

8. double xmult(double x1,double y1,double x2,double y2){ return (x1*y2-y1*x2);}

9. int gcd(int a,int b) { return b?gcd(b,a%b):a;}

10. int abs(int x) { return x>0?x:(0-x);}

11.

12. double area_polygon(int n, point *p)

13. {

14.        int i;

15.        double ret=0;

16.        for (i=0; i<n; ++i)

17.               ret += xmult(p[i].x,p[i].y,p[i+1].x,p[i+1].y);

18.        ret += xmult(p[n-1].x,p[n-1].y,p[0].x,p[0].y);

19.        return ret/2;

20. }

21.

22. void solve()

23. {

24.        int i,n;

25.        point p[MAXN+1];

26.        int c,e;

27.        double a;

28.        int dx,dy;

29.        scanf ("%d",&n);

30.        p[0].x = p[0].y = 0;

31.        e = 0;

32.        for (i=0; i<n; ++i){

33.               scanf ("%d %d",&dx,&dy);

34.               e += gcd(abs(dx),abs(dy));

35.               p[i+1].x = p[i].x+dx;

36.               p[i+1].y = p[i].y+dy;

37.        }

38.        a = area_polygon(n+1,p);

39.        c = (int)(a+1-0.5*(double)e);

40.        printf ("%d %d %.1lf/n/n",c,e,a);

41. }

42.

43. int main()

44. {

45. #ifdef ONLINE_JUDGE

46. #else

47.        freopen("1032.txt","r",stdin);

48. #endif

49.        int i,t;

50.        while (scanf ("%d",&t) != EOF)

51.               for (i=1; i<=t; ++i){

52.                      printf ("Scenario #%d:/n",i);

53.                      solve();

54.               }

55. #ifdef ONLINE_JUDGE

56. #else

57.        fclose(stdin);

58. #endif

59.        return 0;

60. }

#### zoj 1032 || poj 1265 Area 2

2011-04-26 13:42:00

#### poj Area 1265 求面积+ 多边形边上的点的个数+ 多边形内点个数

2014-06-26 15:08:06

#### CF #329

2015-11-05 17:49:36

#### CF #308 (Div. 2)

2015-07-08 22:33:55

#### 2016 UESTC Training for Math(没有B H I)

2016-05-29 22:23:53

#### ZOJ1032-Area 2（已知点坐标求多边形面积，求线段上的整点数量，pick定理）

2017-04-19 20:06:13

#### ZOJ1032 Area 2

2010-10-01 12:29:00

#### ZOJ1032

2016-02-29 20:51:29

#### 【cm-3】汇编中的句子:AREA |.text|, CODE, READONLY, ALIGN=2详解

2015-07-29 16:28:59

#### OCP 1Z0 053 27

2014-06-30 21:00:41