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

WA 自己测过都没问题

Posted by chenjinying at 2009-01-12 22:33:08 on Problem 1657
#include "stdio.h"
#include "math.h"

int a(int m1,int n1,int m2,int n2)
{
	int k1,k2;
	if(m1==m2)return abs(n1-n2);
	else if(n1==n2)return abs(m1-m2);
	else if(abs(m1-m2)==abs(n1-n2))return abs(m1-m2);
	else
	{
		k1=abs(m1-m2);
		k2=abs(n1-n2);
		if(k1>k2)return k1;
		else return k2;
	}
}

void main()
{
	int t,i,K;
	int m1,m2,n1,n2;
	char m[2],n[2];
	scanf("%d",&t);
	for(i=1;i<=t;i++)
	{
		scanf("%s %s",&m,&n);
		m1=m[0]-96;
		n1=m[1]-48;
		m2=n[0]-96;
		n2=n[1]-48;

		printf("%d ",a(m1,n1,m2,n2));//---王

		if(abs(m1-m2)==abs(n1-n2) || m1==m2 || n1==n2)printf("1 ");//--后
		else{printf("2 ");}

		if(m1==m2 || n1==n2)printf("1 ");//--车
		else{printf("2 ");}

		if((m1+n1)%2 != (m2+n2)%2)//----象
			printf("Inf\n");
		else
		{
			if(abs(m1-m2)==abs(n1-n2))printf("1\n");
			else{printf("2\n");}
		}
	}
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator