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:各位同学请帮我看一下,什么地方出了问题In Reply To:Re:各位同学请帮我看一下,什么地方出了问题 Posted by:apolor at 2004-05-15 21:56:24 > 算法错了,看下面的: > > #include<iostream.h> > #include<math.h> > > void main(){ > char x[25][8],y[25][8]; > int n,i,ax,ay; > cin>>n; > for(i=0;i<n;i++) > cin>>x[i]>>y[i]; > for(i=0;i<n;i++){ > ax=abs(x[i][0]-y[i][0]); > ay=abs(x[i][1]-y[i][1]); > if(ax>ay) > cout<<ax<<" "; > else cout<<ay<<" "; > > if(ax==ay||ax==0||ay==0) > cout<<"1 "; > else cout<<"2 "; > > if(ax==0||ay==0) > cout<<"1 "; > else cout<<"2 "; > > if((ax+ay)%2==0) > if(ax==ay) > cout<<"1 "<<endl; > else > cout<<"2 "<<endl; > else cout<<"Inf "<<endl; > } > } > 没有考虑到起点和终点在同一处的情况。如果是在同一点的话,跳的步数全为0,这样我的程序终于通过了。不过我有一个疑问,就是起点和终点到底能否在同一处,如果可以的话,那么某一方就可以不走,而让对方一直走下去,有这个规则吗?所以我认为如果起点和终点在同一处,王、后、车、象所需的最少步数皆为2。 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator