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:答案都没啥问题,为什么会WA啊,有没有大神看看In Reply To:答案都没啥问题,为什么会WA啊,有没有大神看看 Posted by:ChefsSalad at 2022-10-08 15:59:59 > import java.util.*; > > public class p1002 { > > public static void main(String[] args) { > Scanner reader=new Scanner(System.in); > int n=reader.nextInt(),m=n+1; > HashMap<String,Integer> table=new HashMap<String,Integer>(); > String str,string=""; > int i,len,number,count=0; > char letter; > while(m--!=0){ > str=reader.nextLine(); > len=str.length(); > count=0; > for(i=0;i<len;i++){ > letter=str.charAt(i); > if(letter=='-') > continue; > else if(letter>='0'&&letter<='9') > string+=letter; > else { > number=(int)letter; > if(letter>='A'&&letter<='P') > number++; > number=number/3+28; > string+=(char)number; > } > count++; > if(count==3) > string+="-"; > > } > if(table.containsKey(string)) > table.put(string,table.get(string)+1); > else table.put(string,1); > string=""; > } > count=0; > String arr[]=new String[n]; > for(String key : table.keySet()){ > i=table.get(key); > if(i==1) > continue; > string=key; > i+=48; > string+=" "+(char)i; > arr[count]=string; > count++; > } > if(count==0) > System.out.println("No duplicates."); > else { > Arrays.sort(arr,0,count); > for(i=0;i<count;i++) > System.out.println(arr[i]); > > } > reader.close(); > } > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator