Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## Re:pick 定理+边上的顶点数 恩 学习了 ，不过为什么代码C++能过G++过不了？大牛们能帮我看下吗

Posted by Gamor at 2010-03-23 10:58:44 on Problem 1265
In Reply To:pick 定理+边上的顶点数 恩 学习了 ，不过为什么代码C++能过G++过不了？大牛们能帮我看下吗 Posted by:abilitytao at 2009-08-10 22:45:07
```> #include<iostream>
> #include<cmath>
> #include<cstdio>
> using namespace std;
>
> struct point{double x,y;};
>
> int EXTENDED_EUCLID(int a,int b,int &x,int &y)//扩展欧几里德算法
> {
>     if(b==0)
>     {
>         x=1;
>         y=0;
>         return a;
>     }
>     int r=EXTENDED_EUCLID(b,a%b,x,y);
>     int temp=x;
>     x=y;
>     y=temp-a/b*y;
>     return r;
> }
>
> //计算多边形面积,顶点按顺时针或逆时针给出
> double area_polygon(int n,point* p){
> 	double s1=0,s2=0;
> 	int i;
> 	for (i=0;i<n;i++)
> 		s1+=p[(i+1)%n].y*p[i].x,s2+=p[(i+1)%n].y*p[(i+2)%n].x;
> 	return fabs(s1-s2)/2;
> }
> point p[103];
> int main()
> {
> 	int testcase;
> 	int n;
> 	int i,j;
> 	double I,E,s;
> 	int x,y;
>
> 	scanf("%d",&testcase);
> 	for(i=1;i<=testcase;i++)
> 	{
> 		E=0;
>
> 		scanf("%d",&n);
> 		point temp;
> 		temp.x=temp.y=0;
> 		p[0]=temp;
> 		double dx,dy;
> 		for(j=1;j<=n;j++)
> 		{
>
> 			scanf("%lf%lf",&dx,&dy);
> 			temp.x+=dx;
> 			temp.y+=dy;
> 			p[j]=temp;
> 		}
> 		s=area_polygon(n,p);
> 		for(j=1;j<n;j++)
> 		{
>
> 			E+=EXTENDED_EUCLID((int)(abs(p[j].x-p[j-1].x)+0.1),(int)(abs(p[j].y-p[j-1].y)+0.1),x,y);
> 		}
> 		E+=EXTENDED_EUCLID((int)(abs(p[n-1].x-p[0].x)+0.1),(int)(abs(p[n-1].y-p[0].y)+0.1),x,y);
>
> 		I=s+1-E/2;
> 		printf("Scenario #%d:\n",i);
> 		printf("%.0lf %.0lf %.1lf\n\n",I,E,s);
>
>
>
> 	}
> 	return 0;
>
>
> }

```

Followed by: