#abc367c. C - Enumerate Sequences
C - Enumerate Sequences
Score : points
问题陈述
以升序的字典序打印所有长度为 的整数序列,满足以下条件:
- 第 个元素在 到 (包括 和 )之间。
- 所有元素的和是 的倍数。
什么是序列的字典序?如果满足以下条件之一,则序列 字典序小于 序列 :
- 且 。
- 存在一个整数 使得以下两个条件同时成立:
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
Print all integer sequences of length that satisfy the following conditions, in ascending lexicographical order.
- The -th element is between and , inclusive.
- The sum of all elements is a multiple of .
What is lexicographical order for sequences? A sequence is lexicographically smaller than if either 1. or 2. below holds:
- and .
- There exists an integer such that both of the following are true:
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer in the following format, where is the number of sequences to print, the -th of which is :
Sample Input 1
3 2
2 1 3
Sample Output 1
1 1 2
2 1 1
2 1 3
There are three sequences to be printed, which are in lexicographical order.
Sample Input 2
1 2
1
Sample Output 2
There may be no sequences to print.
In this case, the output can be empty.
Sample Input 3
5 5
2 3 2 3 2
Sample Output 3
1 1 1 1 1
1 2 2 3 2
1 3 1 3 2
1 3 2 2 2
1 3 2 3 1
2 1 2 3 2
2 2 1 3 2
2 2 2 2 2
2 2 2 3 1
2 3 1 2 2
2 3 1 3 1
2 3 2 1 2
2 3 2 2 1