Zeros and ones (2) P45965


Statement
 

pdf   zip

thehtml

Write a program to print all the combinations of no zeros and o ones, for some given n and o.

Input

Input consists of n and o, two natural numbers such that n > 0 and 0 ≤ on.

Output

Print all the combinations of no zeros and o ones, one per line and in lexicographical order.

Public test cases
  • Input

    5 2
    

    Output

    0 0 0 1 1
    0 0 1 0 1
    0 0 1 1 0
    0 1 0 0 1
    0 1 0 1 0
    0 1 1 0 0
    1 0 0 0 1
    1 0 0 1 0
    1 0 1 0 0
    1 1 0 0 0
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Python
    User solutions
    C C++ Java Python