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

一直runtime 测试用例也是都过了

Posted by iiii4646 at 2020-02-17 10:52:48 on Problem 1002
    package com.company;

    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.Scanner;
    import java.util.Set;

    public class Main {

            public static void main(String args[]) {
                Scanner cin = new Scanner(System.in);
                int count = cin.nextInt();
                HashMap<String, Integer> hm = new HashMap<String, Integer>();
                for(int i=0;i<count;i++){
                    String input = cin.next();
                    if(input==""||input==null){
                        i--;
                        continue;
                    }
                    input = input.toUpperCase();
                    StringBuffer stringBuffer = new StringBuffer();
                    for(int j=0;j<input.length();j++){
                        int charactor = input.charAt(j);
                        if(charactor!=45){
                            if(charactor<64){
                                stringBuffer.append(input.charAt(j));
                            }else{
                                int index = charactor - 65;
                                int muti = index / 3;
                                if(charactor==89)
                                    muti=7;
                                stringBuffer.append(muti+2);
                            }
                        }
                        if(stringBuffer.length()==3){
                            stringBuffer.append('-');
                        }
                    }
                    String s = stringBuffer.toString();
                    Integer integer = hm.get(s);
                    if(integer==null){
                        integer=0;
                    }
                    hm.put(s,integer+1);
                }
                Set<String> strings = hm.keySet();
                Iterator<String> iterator = strings.iterator();
                while (iterator.hasNext()) {
                    String next = iterator.next();
                    System.out.println(next+' '+hm.get(next));
                }
            }

    }

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