CF 9D. How many trees?(dp)

题目链接

以前做过类似的,USACO,2.3,开始数组开小了,导致数据乱了,然后超数据范围了,。。

 #include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;
#define LL __int64
LL dp[][][];
LL c[][];
int main()
{
int i,j,n,k,u,h;
for(i = ; i <= ; i ++)
{
c[i][] = ;
}
for(i = ; i <= ; i ++)
{
for(j = ; j <= ; j ++)
c[i][j] = c[i-][j-] + c[i-][j];
}
dp[][][] = ;
scanf("%d%d",&n,&h);
for(i = ; i < n; i ++)
{
for(j = ; j <= n; j ++)
{
for(k = ; k <= n; k ++)
{
if(dp[i][j][k] == ) continue;
for(u = ; u <= *k; u ++)
dp[i+][j+u][u] += c[*k][u]*dp[i][j][k];
}
}
}
LL ans = ;
for(i = h; i <= n; i ++)
{
for(k = ; k <= n; k ++)
{
ans += dp[i][n][k];
}
}
printf("%I64d\n",ans);
return ;
}
上一篇:web3.js


下一篇:Sencha Touch2 时间轴ListPanel