CF1188C.Array Beauty
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Let's call beauty of an array b1,b2,…,bn ( n>1 ) — 1≤i<j≤nmin∣bi−bj∣ .
You're given an array 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 998244353 .
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.
输入格式
The first line contains integers n,k ( 2≤k≤n≤1000 ).
The second line contains n integers a1,a2,…,an ( 0≤ai≤105 ).
输出格式
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 998244353 .
输入输出样例
输入#1
4 3 1 7 3 5
输出#1
8
输入#2
5 5 1 10 100 1000 10000
输出#2
9
说明/提示
In the first example, there are 4 subsequences of length 3 — [1,7,3] , [1,3,5] , [7,3,5] , [1,7,5] , each of which has beauty 2 , so answer is 8 .
In the second example, there is only one subsequence of length 5 — the whole array, which has the beauty equal to ∣10−1∣=9 .