Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
547 B
1
Indexable
import java.util.Scanner;

public class P19 {
    public static boolean check(String s) {
        return s.endsWith("1");
    }

    public static void solve(int n, String s) {
        if (s.length() == n) {
            System.out.println(s);
            return;
        }
        solve(n, s + "0");
        if (!check(s)) {
            solve(n, s + "1");
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        solve(n, "");
    }
}
Leave a Comment