Problem 3818 --Pty loves sequence

3818: Pty loves sequence

"
Time Limit $6$ 秒/Second(s) Memory Limit $128$ 兆字节/Megabyte(s)
提交总数 $0$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
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 ≤ 109).
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 xth 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

推荐代码 查看3818 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战

赛题来源/所属竞赛 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛