Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:为什么WA啊!!!In Reply To:为什么WA啊!!! Posted by:xiaohuang_17 at 2009-08-09 22:42:50 > > #include <iostream> > using namespace std; > struct Node > { > double startx,starty; > double endx,endy; > }s[100002]; > bool signal[100002]; > int ans[1002]; > int Judge(Node a,Node b) > { > double t1=(a.startx-b.endx)*(b.starty-b.endy)-(a.starty-b.endy)*(b.startx-b.endx);//叉积 > double t2=(b.starty-b.endy)*(a.endx-b.endx)-(b.startx-b.endx)*(a.endy-b.endy); > double t3=(b.endx-a.startx)*(a.endy-a.starty)-(b.endy-a.starty)*(a.endx-a.startx); > double t4=(a.endy-a.starty)*(b.startx-a.startx)-(a.endx-a.startx)*(b.starty-a.starty); > if(t1*t2<0&&t3*t4<0) > return 1; > else > return 0; > } > > int main() > { > int n; > int i,j,t,count; > while(scanf("%d",&n)!=EOF) > { > if(n==0)break; > else > { > count=0; > for(i=0;i<n;++i) > { > scanf("%lf%lf%lf%lf",&s[i].startx,&s[i].starty,&s[i].endx,&s[i].endy); > getchar(); > signal[i]=true; > } > for(i=n-1;i>=0;--i) > { > if(signal[i]==true) > { > for(j=0;j<i;++j) > { > if(signal[j]==true) > { > t=Judge(s[i],s[j]);//线段s[i]和s[j]是否相交 > if(t==1)signal[j]=false; > } > } > ans[count++]=i+1; > if(count>1002)break; > } > } > printf("Top sticks: "); > for(i=count-1;i>0;--i) > { > printf("%d, ",ans[i]); > } > printf("%d.\n",ans[0]); > } > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator