codeforces Round 572 F. Array Beauty

 

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.

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值