https://www.luogu.org/problemnew/solution/CF1188C
https://blog.csdn.net/huayunhualuo/article/details/95616635
更正一下第二篇
dp[index][len] ,前index个数长度为len的子序列的个数。
关键是得想明白差分 哈哈
C. Array Beauty
time limit per test
5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Let's call beauty of an array ?1,?2,…,??b1,b2,…,bn (?>1n>1) — min1≤?<?≤?|??−??|min1≤i<j≤n|bi−bj|.
You're given an array ?1,?2,…??a1,a2,…an and a number ?k. Calculate the sum of beauty over all subsequences of the array of length exactly ?k. As this number can be very large, output it modulo 998244353998244353.
A sequence ?a is a subsequence of an array ?b if ?a can be obtained from ?b by deletion of several (possibly, zero or all) elements.
Input
The first line contains integers ?,?n,k (2≤?≤?≤10002≤k≤n≤1000).
The second line contains ?n integers ?1,?2,…,??a1,a2,…,an (0≤??≤1050≤ai≤105).
Output
Output one integer — the sum of beauty over all subsequences of the array of length exactly ?k. As this number can be very large, output it modulo 998244353998244353.
Examples
input
Copy
4 3
1 7 3 5
output
Copy
8
input
Copy
5 5
1 10 100 1000 10000
output
Copy
9
Note
In the first example, there are 44 subsequences of length 33 — [1,7,3][1,7,3], [1,3,5][1,3,5], [7,3,5][7,3,5], [1,7,5][1,7,5], each of which has beauty 22, so answer is 88.
In the second example, there is only one subsequence of length 55 — the whole array, which has the beauty equal to |10−1|=9|10−1|=9.