The topics are as follows:
The 19-letter sequence of ABCD...S is repeated 106 times to get a string of length 2014.
Next, delete the 1th letter (the first letter a), and the 3rd, 5th, and all odd-numbered positions.
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.
The answer is a lowercase letter, please submit the answer via the browser. Do not fill in any extra content.
Public class to guess the letter { Public Static voidMain (string[] args) {StringStr="ABCDEFGHIJKLMNOPQRS"; String str1 =""; for(inti =0; I <106; i++) {str1 = str1 +Str; } System.out.println (Str1.length ());Boolean[] arr =New Boolean[Str1.length ()]; for(inti =0; i < arr.length; i++) {Arr[i] =true;//Subscript True indicates that the letter is still in the circle}intLeftcount = Str1.length ();intCountnum =0;int Index=0; while(Leftcount >1) {if(arr[Index] ==true) {//When in a circle if(Countnum%2==0) {//subscript is evenarr[Index] =false;//The letter exits the Circleleftcount--;///number of remaining letters minus one} countnum++; }Index++;//per newspaper, subscript plus one if(Index= = Str1.length ()) {//is the number of loops, when the current index is greater than N, the description has been counted a circle, Index=0;//Set the subscript to zero to start again. Countnum =0; } }//Print out the last for(inti =0; I < str1.length (); i++) {if(Arr[i] = =true) {System.out.println (i);//The output indicates a letter labeled 1023 (1024th), which is: Q} } }}
The second method of solution:
Public class to guess the letter 1 { Public Static voidMain (string[] args) {String str2 =""; StringStr="ABCDEFGHIJKLMNOPQRS"; for(inti =0; I < the; i++) {Str=Str+"ABCDEFGHIJKLMNOPQRS"; } System.out.println (Str. Length ()); while(Str. Length ()! =1) { for(inti =0; I <Str. Length (); i++) {ifI2==1) {str2 + =Str. charAt (i); } }Str= STR2; STR2 =""; System.out.println (Str); } }}
The second better understanding, the answer is easier to find
Java algorithm Questions--guess letters/killing games