#P1329. 数列
数列
Description
There is a sequence , where , and for any term it holds that (). Let $s = \sum_{i = 1}^n a_i = a_{1} + a_{2} + \cdots + a_{n}$ denote the sum of the first terms.
Given the length and the sum of the first terms, do the following:
- Output the total number of sequences that satisfy the conditions, modulo .
- Output up to sequences that satisfy the conditions (if fewer than exist, output all of them).
Input Format
The input contains a single line with two integers, the sequence length and the sum .
Output Format
This problem uses a Special Judge.
On the first line, output a single integer , the total number of valid sequences modulo .
Then output several lines, each containing integers, describing one valid sequence.
4 0
2
0 -1 0 1
0 1 0 -1
Hint
-
Constraints
For all testdata, it is guaranteed that , .
-
Notes
Special Judge provider:
user/230249
Translated by ChatGPT 5
京公网安备 11011102002149号