当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7077:Pty loves sequence

题目描述
A positive integer sequence A is considered good if and only if the following conditions are satisfied:

1. The length of A equals to n.
2. Suppose that k is the maximum value of A, A should contain [1,2,3...k-1,k] as a subsequence.

A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.

First, Pty wants to know the number of good sequences.

Second, for each integer x ∈ [1,n], Pty also wants to know the occurrence number of x in all good sequences.

Since the answers might be very large, print the answers modulo p.

There are T test cases in total.
输入解释
The first line contains a single integer T(1 ≤ T ≤ 10) — the number of test cases.

For each test case, only one line contains two integers n,p (1 ≤ n ≤ 3000,1 ≤ p ≤ $10^9$).
输出解释
For each test case, output two lines.

The first line contains a integer - the number of good sequences modulo p.

The second line contains n integers separated by spaces-The $x^{th}$ integer represent the occurrence number of x in all good sequences modulo p.
输入样例
2
3 3
3 1216

输出样例
0
1 1 1
6
10 7 1


该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7077

最后修改于 2021-10-23T19:11:20+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
12000/6000MS(Java/Others) 524288/524288K(Java/Others)