【树状数组】Hdu5542 The Battle of Chibi

该博客介绍了一个利用树状数组解决数论问题的案例,具体是针对一个数列求长度为M的严格递增子序列的数量。题目要求在不超过10^9的范围内,计算所有可能的递增子序列,结果需要对10^9+7取模。博主分析了暴力解法,并提出了通过树状数组优化的解决方案,以适应题目所给的数据范围。
摘要由CSDN通过智能技术生成

Description

给定一个长度为N的数列A,求A有多少个长度为M的严格递增子序列。1≤M≤N≤1000,序列A中的数的绝对值不超过
 〖10〗^9。因为答案可能很大,你只需要输出对 〖10〗^9+7 取模后的结果。

Input

The first line of the input gives the number of test cases, T(1≤100). T test cases follow.
Each test case begins with two numbers N(1≤N≤103) and M(1≤M≤N), 
indicating the number of information and number of information Gai Huang will select. 
Then N numbers in a line, the ith number ai(1≤ai≤10^9) 
indicates the value in Cao Cao's opinion of the ith information in happening order.

Output

For each test case, output one line containing Case #x: y, 
where x is the test case number (starting from 1) and y is the ways Gai Huang can select the information.
The result is too large, and you need to output the result mod by 1000000007(10^9+7).

Sample Input

2
3 2
1 2 3
3 2
3 2 1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值