您的位置:首页 > 其它

USACO: Cow Pedigrees dp

2013-03-08 20:03 225 查看
/*
ID: Jang Lawrence
PROG: nocows
LANG: C++
*/
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long lng;
int  f(lng x)
{
return (x%9901+9901)%9901;
}
int n,k;
lng dp[201][101];
int main()
{
#ifndef  DEBUG
freopen("nocows.in","r",stdin);
freopen("nocows.out","w",stdout);
#endif
scanf("%d%d",&n,&k);
for(int i=1;i<=k;++i) dp[1][i]=1;
for(int i=3;i<=n;i+=2)
for(int j=1;j<=k;++j)
{
for(int s=1;s<i-1;s+=2)
dp[i][j]=f(dp[i][j]+dp[s][j-1]*dp[i-1-s][j-1]);
}
int u=f(dp
[k]-dp
[k-1]);
printf("%d\n",u);
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: