| ||||||||||
| 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 | |||||||||
为什么测试数据全过,但结果确实WA啊?import java.io.*;
import java.util.*;
public class Main
{
public static void main(String args[]) throws Exception
{
int i,j,k,original,last,m,n,num;
StringBuffer str1=new StringBuffer();
StringBuffer str2=new StringBuffer();
Scanner cin=new Scanner(System.in);
i=cin.nextInt();
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
for(j=0;j<i;j++)
{
num=0;
str1.append(in.readLine());
str2.append(in.readLine());
original=str1.length()+str2.length();
for(k=0;k<str1.length();k++)
{
for(m=0;m<str2.length();m++)
{
if(str1.charAt(k)==str2.charAt(m))
{
str2.deleteCharAt(m);
str2.trimToSize();
num++;
}
}
}
System.out.println("Case #"+(j+1)+": "+(original-num*2));
str1=new StringBuffer();
str2=new StringBuffer();
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator