2543. El Dorado

单点时限: 2.0 sec

内存限制: 256 MB

Bruce Force has gone to Las Vegas, the El Dorado for gamblers. He is interested especially in one betting game, where a machine forms a sequence of n numbers by drawing random numbers. Each player should estimate beforehand, how many increasing subsequences of length k will exist in the sequence of numbers.

A subsequence of a sequence a1, …, an is defined as ai1, …, ail, where 1 ≤ i1 < i2 < … < il ≤ n. The subsequence is increasing, if aij-1 < aij for all 1 < j ≤ l.

Bruce doesn’t trust the Casino to count the number of increasing subsequences of length k correctly. He has asked you if you can solve this problem for him.

输入格式

The input contains several test cases. The first line of each test case contains two numbers n and k (1 ≤ k ≤ n ≤ 100), where n is the length of the sequence drawn by the machine, and k is the desired length of the increasing subsequences. The following line contains n pairwise distinct integers ai (-10000 ≤ ai ≤ 10000 ), where ai is the ith number in the sequence drawn by the machine.

The last test case is followed by a line containing two zeros.

输出格式

For each test case, print one line with the number of increasing subsequences of length k that the input sequence contains. You may assume that the inputs are chosen in such a way that this number fits into a 64 bit signed integer

样例

Input
10 5
1 2 3 4 5 6 7 8 9 10
3 2
3 2 1
0 0
Output
252
0

5 人解决,17 人已尝试。

8 份提交通过,共有 48 份提交。

8.5 EMB 奖励。

创建: 16 年,5 月前.

修改: 8 年前.

最后提交: 6 天,19 小时前.

来源: N/A

题目标签