tju 3017 El Dorado(sdutacm 2384)

http://acm.tju.edu.cn/toj/showp3017.html

http://acm.sdut.edu.cn/web/problem.php?action=showproblem&problemid=2384

思路:dp题,自己脑子太笨了,代码如下,提醒一下自己;

View Code
#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;
}



posted @ 2012-03-04 20:42  LT-blogs  阅读(172)  评论(0编辑  收藏  举报