#K1126. Exhibition Combinations

    ID: 23429 Type: Default 1000ms 256MiB

Exhibition Combinations

Exhibition Combinations

Problem Statement:

Given two integers ( n ) and ( k ), where ( n ) represents the total number of items and ( k ) represents the number of items to be selected, your task is to list all unique combinations (exhibitions) of ( k ) items chosen from ( n ) items. The items are labeled from 1 to ( n ) and each combination should be printed in increasing order. If ( k > n ), then no exhibition is possible.

You should first output the total number of possible exhibitions on the first line. If there exists at least one valid exhibition (i.e. when ( k \leq n )), then print each exhibition on a new line with the selected item numbers separated by a space. Otherwise, if ( k > n ), simply output 0.

inputFormat

The input is read from STDIN and consists of two integers ( n ) and ( k ) separated by space.

outputFormat

Print the total number of unique exhibitions on the first line. For valid combinations (i.e. when ( k \leq n )), output each exhibition on a new line as space-separated integers in ascending order. If ( k > n ), print 0.## sample

5 2
10

1 2 1 3 1 4 1 5 2 3 2 4 2 5 3 4 3 5 4 5

</p>