8655: Matryoshka Doll

内存限制:128 MB 时间限制:3 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:2 通过:1

题目描述

zyb bought n matryoshka dolls during his visit to Moscow, with sizes a1,a2,,an, respectively, sorting from smallest to largest.

A matryoshka of size ii can be put into another matryoshka of size j if and only if jir, where rr is some given integer parameter.

zyb wishes to divide all n matryoshka dolls into kk groups, such that one can form a nestedmatryoshka doll in each group, where a group of matryoshka dolls with indices c1,c2,...,cm(1c1<c2<...<cmn) can form a nested matryoshka doll ∀1i<m,aci+raci+1.

zyb wants to know how many ways there are to divide the n dolls into k groups satisfying the requirement above. Note that divisions such as1,2,3,4 and 3,4,1,2 are considered the same way. As the answer may be too large, you only need to output the answer modulo 998244353

输入格式

The first line contains an integer T(1T20), denoting the number of test cases.

For each test case, the first line contains three integers n,k,r(1kn5000,1r109), denoting the number of matryoshka dolls, the number of groups zyb wants to divide into, and the parameter, respectively.

The next line contains n integers a1,a2,,an(1a1a2...an109), denoting the sizes of the matryoshka dolls.

It is guaranteed that n50000 over all test cases.

输出格式

For each test case, output an integer in a line, denoting the answer taken modulo 998244353

输入样例 复制

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

输出样例 复制

3
2