| ||||||||||
| 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:用不着bfs,找找规律就可以了In Reply To:Re:0K 0MS怎么出来的?难道直接调用输出文件? Posted by:dawei007 at 2010-04-25 17:47:57 我把我的代码粘这吧,写的很烂,仅仅是参考~见谅
#include<stdio.h>
#include<math.h>
int main()
{
int n,a,b;
char x,y;
scanf("%d",&n);
getchar();
while(n--)
{
x=getchar();
scanf("%d",&a);
getchar();
y=getchar();
scanf("%d",&b);
getchar();
//王
int w0=(int)fabs((float)(x-y));
int w=(int)fabs((float)(a-b));
w=w0<w?w:w0;
printf("%d ",w);
//后
if(x==y&&a==b)
printf("0 ");
else if(x==y||a==b||w0==w)
printf("1 ");
else
printf("2 ");
//车
if(x==y&&a==b)
printf("0 ");
else if(x==y||a==b)
printf("1 ");
else
printf("2 ");
//象
int w1=(int)fabs((float)(x-y));
w1%=2;
int w2=(int)fabs((float)(a-b));
w2%=2;
if(x==y&&a==b)
printf("0\n");
else if(w0==w)
printf("1\n");
else if((w1+w2)%2!=0)
printf("Inf\n");
else
printf("2\n");
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator