题目描述
s01串初始为" 0"
按以下方式变换
0变1,1变01
数据规模和约定
0~19
输入
1个整数(0~19)
输出
n次变换后s01串
样例输入
3
样例输出
101
import java.util.Scanner;
public class s01串 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String a = "0";
while (n > 0) {
String b = "";
for (int i = 0; i < a.length(); i++) {
if (a.charAt(i) == '0')
b += "1";
else if (a.charAt(i) == '1')
b += "01";
}
a = b;
n--;
}
System.out.println(a);
}
}