#abc263c. C - Monotonically Increasing

C - Monotonically Increasing

Score : 300300 points

问题描述

打印所有严格递增的整数序列,其长度为 NN,且所有元素均在 11MM(包含)之间,按照字典序升序排列。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Print all strictly increasing integer sequences of length NN where all elements are between 11 and MM (inclusive), in lexicographically ascending order.

Notes

For two integer sequences of the same length A1,A2,,ANA_1,A_2,\dots,A_N and B1,B2,,BNB_1,B_2,\dots,B_N, AA is said to be lexicographically earlier than BB if and only if:

  • there is an integer ii (1iN)(1 \le i \le N) such that Aj=BjA_j=B_j for all integers jj satisfying 1j<i1 \le j < i, and Ai<BiA_i < B_i.

An integer sequence A1,A2,,ANA_1,A_2,\dots,A_N is said to be strictly increasing if and only if:

  • Ai<Ai+1A_i < A_{i+1} for all integers ii (1iN1)(1 \le i \le N-1).

Constraints

  • 1NM101 \le N \le M \le 10
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM

Output

Print the sought sequences in lexicographically ascending order, each in its own line (see Sample Outputs).

Sample Input 1

2 3

Sample Output 1

1 2 
1 3 
2 3 

The sought sequences are (1,2),(1,3),(2,3)(1,2),(1,3),(2,3), which should be printed in lexicographically ascending order.

Sample Input 2

3 5

Sample Output 2

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

update @ 2024/3/10 11:07:26