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 |
提交不成功,玩不转...谁能帮我提交一下呢? 我觉得没错啊 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator