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 xinhe at 2007-10-05 21:15:13 on Problem 2681
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:
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