Zeros and ones (1)

Write a backtracking program to print all the combinations of zz zeros and oo ones such that z+o=nz + o = n, for a given nn.

Input

Input consists of a natural number n>0n > 0.

Output

Print all the combinations of zz zeros and oo ones such that z+o=nz + o = n, one per line and in lexicographical order.

Observation

Although a backtracking program is not really necessary to solve this exercise, implement it anyway for the sake of practice.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T10:03:40.957Z

© Jutge.org, 2006–2026.
https://jutge.org