1 /*2 The 19-letter sequence of ABCD...S is repeated 106 times to get a string of length 2014. 3 Next, delete the 1th letter (the first letter a), and the 3rd, 5th, and all odd-numbered positions. 4 get the new string and then delete the odd position letter action. In this case, there is only one letter left, please write the letter. 5 The answer is a lowercase letter, please submit the answer via the browser. Do not fill in any extra content. 6 */
7 Public classMain {8 Public Static voidMain (string[] args) {9String s = "ABCDEFGHIJKLMNOPQRS";TenString str = ""; One for(inti = 0; I < 106; i++) { Astr + = s;//Repeat Stitching - } - System.out.println (Str.length ()); the BooleanArr[] =New Boolean[Str.length ()]; - for(inti = 0; i < arr.length; i++) { -Arr[i] =true;//Mark whether the letter has been deleted (false to delete) - } + inti = 0;//Subscript for old strings (always str) - intCountnum = 0;//the subscript of a new string + intLeftnum = Str.length ();//the number of letters left after deletion A at while(Leftnum > 1) {//title description at the end of the day only one letter left - if(Arr[i] = =true) {//If the letter has not been deleted - if(countnum% 2 = = 0) {//If the subscript of the new string is an even number -Arr[i] =false;//Delete the letter -leftnum--;//number of remaining letters-1 - } incountnum++;//traverse a new string (a string of letters not deleted) - } toi++;//traversal of old strings (always str) + - if(i = = Str.length ()) {//if the loop is completed again, (the title describes the new string and then the action of deleting the odd position letter), the cyclic deletion theCountnum = 0;//set to 0 start again *i = 0; $ }Panax Notoginseng } - for(intj = 0; J < Arr.length; J + +) { the if(Arr[j] = =true) { + System.out.println (Str.charat (j)); A } the } + } -}
2014 Fifth annual Blue Bridge Cup Java Undergraduate B group _ guess the alphabet