Multisets (3) P22110


Statement
 

pdf   zip

html

Write a program that, given two numbers n and t, prints all the multisets with t numbers that can be made up with {1, …, n}.

Input

Input consists of a natural number n > 0, followed by a natural number t ≥ 0.

Output

Print all the multisets of size t that can be made up with {1, …, n}. The numbers inside each multiset must appear in non-decreasing order.

Information about the checker

You can print the solutions to this exercise in any order.

Public test cases
  • Input

    3 3
    

    Output

    {3,3,3}
    {2,3,3}
    {2,2,3}
    {2,2,2}
    {1,3,3}
    {1,2,3}
    {1,2,2}
    {1,1,3}
    {1,1,2}
    {1,1,1}
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Salvador Roura
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++ Python