CF1188C.Array Beauty

普及/提高-

通过率:0%

时间限制:5.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Let's call beauty of an array b1,b2,,bnb_1, b_2, \ldots, b_n (n>1n \gt 1) — min1i<jnbibj\min\limits_{1 \leq i \lt j \leq n} |b_i - b_j|.

You're given an array a1,a2,ana_1, a_2, \ldots a_n and a number kk. Calculate the sum of beauty over all subsequences of the array of length exactly kk. As this number can be very large, output it modulo 998244353998244353.

A sequence aa is a subsequence of an array bb if aa can be obtained from bb by deletion of several (possibly, zero or all) elements.

我们定义一个数组 b1,b2,,bnb_1, b_2, \ldots, b_n(其中 n>1n \gt 1)的优美值为:

min1i<jnbibj\min\limits_{1 \leq i \lt j \leq n} |b_i - b_j|。

给定一个数组 a1,a2,,ana_1, a_2, \ldots, a_n 和一个整数 kk,请计算该数组所有长度恰好为 kk 的子序列的优美值之和。由于结果可能非常大,请输出其对 998244353998244353 取模后的值。

若序列 aa 可通过从数组 bb 中删除若干个(可能为零个或全部)元素得到,则称 aabb 的一个子序列

输入格式

The first line contains integers n,kn, k (2kn10002 \le k \le n \le 1000).

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (0ai1050 \le a_i \le 10^5).

第一行包含两个整数 n,kn, k2kn10002 \le k \le n \le 1000)。

第二行包含 nn 个整数 a1,a2,,ana_1, a_2, \ldots, a_n0ai1050 \le a_i \le 10^5)。

输出格式

Output one integer — the sum of beauty over all subsequences of the array of length exactly kk. As this number can be very large, output it modulo 998244353998244353.

输出一个整数——所有长度恰好为 kk 的子序列的“美丽值”之和。由于该数值可能非常大,请对 998244353998244353 取模后输出。

输入输出样例

  • 输入#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 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 101=9|10-1| = 9.

在第一个例子中,长度为 33 的子序列共有 44 个——[1,7,3][1, 7, 3][1,3,5][1, 3, 5][7,3,5][7, 3, 5][1,7,5][1, 7, 5],每个子序列的“美丽值”均为 22,因此答案为 88

在第二个例子中,长度为 55 的子序列仅有一个——即整个数组,其“美丽值”等于 101=9|10-1| = 9

输入解题思路,AI测评打分。不知道怎么写?

首页