Algorithm Training S01 String
Time limit: 1.0s memory limit: 256.0MB
Problem description
S01 string is initially "0"
Transform as follows
0 Change to 01
Input format
1 integers (0~19)
Output format
S01 string after n-Times transformation
Sample input
3
Sample output
101
Data size and conventions
0~19
Example code:
1 ImportJava.util.Scanner;2 3 Public classMain {4 StaticStringBuffer SB =NewStringBuffer ();5 Public Static voidMain (string[] args) {6Scanner sc =NewScanner (system.in);7 intn =sc.nextint ();8 9 if(n = = 0){TenSystem.out.println ("0"); One}Else{ AF (N, "0"); - } - System.out.println (SB); the } - - Private Static voidFintN, String s) { -String str= ""; + - if(N < 0) + return; An--; at for(inti = 0; I < s.length (); i++){ -str = s.substring (i, i+1); - if(Str.equals ("0")){ -str = "1"; -}Else if(Str.equals ("1")){ -str = "01"; in } - to f (n, str); + - if(n = = 0 ){ the sb.append (str); * } $ }Panax Notoginseng } -}
Blue Bridge Cup algorithm training ALGO-139 S01 String