http://acm.tju.edu.cn/toj/showp3017.html
http://acm.sdut.edu.cn/web/problem.php?action=showproblem&problemid=2384
思路:dp题,自己脑子太笨了,代码如下,提醒一下自己;
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;
int s[110] = {0};
int n = 0;
int m = 0;
int dp[110][110] = {0};
int ans = 0;
int main()
{
while(scanf("%d%d",&n,&m),n&&m)
{
ans = 0;
memset(dp,0,sizeof(dp));
for(int i =1;i <= n; ++i)
{
scanf("%d",&s[i]);
dp[i][1] = 1;
for(int k = 2;k <= m; ++k)
{
dp[i][k] = 0;
for(int j = 1;j < i; ++j)
{
if(s[j] < s[i])
dp[i][k] += dp[j][k-1];
}
}
ans = ans + dp[i][m];
}
printf("%d\n",ans);
}
return 0;
}