CF1188C.Array Beauty
普及/提高-
通过率:0%
时间限制:5.00s
内存限制:256MB
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.
我们定义一个数组 b1,b2,…,bn(其中 n>1)的优美值为:
1≤i<j≤nmin∣bi−bj∣。
给定一个数组 a1,a2,…,an 和一个整数 k,请计算该数组所有长度恰好为 k 的子序列的优美值之和。由于结果可能非常大,请输出其对 998244353 取模后的值。
若序列 a 可通过从数组 b 中删除若干个(可能为零个或全部)元素得到,则称 a 是 b 的一个子序列。
输入格式
The first line contains integers n,k (2≤k≤n≤1000).
The second line contains n integers a1,a2,…,an (0≤ai≤105).
第一行包含两个整数 n,k(2≤k≤n≤1000)。
第二行包含 n 个整数 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.
输出一个整数——所有长度恰好为 k 的子序列的“美丽值”之和。由于该数值可能非常大,请对 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.
在第一个例子中,长度为 3 的子序列共有 4 个——[1,7,3]、[1,3,5]、[7,3,5]、[1,7,5],每个子序列的“美丽值”均为 2,因此答案为 8。
在第二个例子中,长度为 5 的子序列仅有一个——即整个数组,其“美丽值”等于 ∣10−1∣=9。
输入解题思路,AI测评打分。不知道怎么写?