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

提交不成功,玩不转...

Posted by youngplayer at 2012-12-21 18:03:51 on Problem 1019
谁能帮我提交一下呢? 我觉得没错啊

public static char getCharAtIndex(int index){
        long num=1;
        long lengthN = 0;
        long buffLength = 0;

//        StringBuffer checkBuffer = new StringBuffer();
//        long lastLength=0;
        while(lengthN < index){
            buffLength +=String.valueOf(num).length();
//            checkBuffer.append(String.valueOf(num));
            num++;

//            lastLength = lengthN;
            lengthN += buffLength;

        }
        long startPos = lengthN;
        char result ='E';
        int arrayIndex = index - 1;
        for(long i=num-1; i > 0; i--){
            String number = String.valueOf(i);
            int numberLength = number.length();
             startPos -= numberLength;
            if(startPos <= arrayIndex ){
                int offset = (int) (arrayIndex - startPos);
                result = number.charAt(offset);
                break;
            }

        }
//        char checkValue = checkBuffer.charAt((int)(arrayIndex-lastLength));
//        if(checkValue != result)
//            System.out.println("checkValue=="+checkValue+" result=="+result);
        return result;
    }

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