| ||||||||||
| 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 | |||||||||
我用JAVA编的这道题目,怎么出现超时啊,大侠帮忙看下import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args)throws Exception {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(br.readLine());
for(int i=0;i<n;i++){
Scanner my=new Scanner(System.in);
char a[]=my.next().toCharArray();
char b[]=my.next().toCharArray();
int x,y;
x=Math.abs(a[0]-b[0]);
y=Math.abs(a[1]-b[1]);
if(x==0&&y==0)System.out.println("0 0 0 0");
else
{
if(x<y)System.out.print(y);
else System.out.print(x);
if(x==y||x==0||y==0)System.out.print(" "+1);
else System.out.print(" "+2);
if(x==0||y==0)System.out.print(" "+1);
else System.out.print(" "+2);
if(Math.abs(x-y)%2!=0)System.out.println(" Inf");
else if(x==y)System.out.println(" "+1);
else System.out.println(" "+2);
}
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator