Describes the recent TopCoder XD encountered a problem, if a number of three times the last three bits is 111, he called the number of small singles. He already knew that the first small bachelor number was 471,471 of the three is 104487111, and now he wants to know what is the number of small bachelor m (m<=10000000000)?
-
- Input
-
- There are multiple sets of test data. The first line is an integer n, which indicates that there are n sets of test data. Each subsequent line has an integer m.
-
- Output
-
- outputs the number of small bachelors of the first M.
-
- Sample input
-
-
11
-
- Sample output
-
471
1 ImportJava.util.Scanner;2 3 Public classMain {4 Public Static voidMain (string[] args) {5Scanner scanner=NewScanner (system.in);6 intT;7 Long N;8 9t=scanner.nextint ();Ten while(true){ One if(t==0) A Break; -t--; - then=Scanner.nextlong (); - -n=471+1000* (n-1); - System.out.println (n); + } - } +}
Number of small singles