题目链接

以前做过类似的,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 ;
}

CF 9D. How many trees?(dp)的更多相关文章

  1. Codeforces 9D How many trees? 【计数类DP】

    Codeforces 9D How many trees? LINK 题目大意就是给你一个n和一个h 问你有多少个n个节点高度不小于h的二叉树 n和h的范围都很小 感觉有无限可能 考虑一下一个很显然的 ...

  2. CF 983B XOR-pyramid(区间dp,异或)

    CF 983B XOR-pyramid(区间dp,异或) 若有一个长度为m的数组b,定义函数f为: \(f(b) = \begin{cases} b[1] & \quad \text{if } ...

  3. Codeforces - 9D - How many trees? - 简单dp - 组合数学

    https://codeforces.com/problemset/problem/9/D 一开始居然还想直接找公式的,想了想还是放弃了.原来这种结构是要动态规划. 状态是知道怎么设了,$t_{nh} ...

  4. Codeforces Round #369 (Div. 2) C. Coloring Trees DP

    C. Coloring Trees   ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the pa ...

  5. CodeForces #369 C. Coloring Trees DP

    题目链接:C. Coloring Trees 题意:给出n棵树的颜色,有些树被染了,有些没有.现在让你把没被染色的树染色.使得beauty = k.问,最少使用的颜料是多少.   K:连续的颜色为一组 ...

  6. C. Coloring Trees DP

    传送门:http://codeforces.com/problemset/problem/711/C 题目: C. Coloring Trees time limit per test 2 secon ...

  7. codeforces 711C C. Coloring Trees(dp)

    题目链接: C. Coloring Trees time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  8. BC.5200.Trees(dp)

    Trees  Accepts: 156  Submissions: 533  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536/6 ...

  9. D. How many trees? DP

    D. How many trees? time limit per test 1 second memory limit per test 64 megabytes input standard in ...

随机推荐

  1. Windows 10 周年更新正式版下载 + win10 快捷键

    Windows 10 周年更新正式版  360云资源总汇(施工中): https://yunpan.cn/c6Svi7Az52XBs (提取码:e5dd)今后提到周年更新版.1607版或RS1版,都是 ...

  2. Bootstrap 排版 笔记

    Bootstrap 使用 Helvetica Neue. Helvetica. Arial 和 sans-serif 作为其默认的字体栈. 使用 Bootstrap 的排版特性,您可以创建标题.段落. ...

  3. 【JAVA网络流之浏览器与服务器模拟】

    一.模拟服务器获取浏览器请求http信息 代码: package p06.TCPTransferImitateServer.p01.ImitateServer; import java.io.IOEx ...

  4. poj 1195:Mobile phones(二维线段树,矩阵求和)

    Mobile phones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 14391   Accepted: 6685 De ...

  5. 記錄一次CRS-0184: Cannot communicate with the CRS daemon的解決

    1. 描述: 使用crs_stat –t 命令查看rac服務,直接報CRS-0184: Cannot communicate with the CRS daemon.錯誤 但是奇怪的是我們的DB是沒有 ...

  6. golang channel basic

    package mainimport ( "fmt" "math/rand" "time")func main() { rand.Seed( ...

  7. .Net Ioc Unity

    Unity 的接口IUnityContainer public interface IUnityContainer : IDisposable IUnityContainer RegisterType ...

  8. SQL常见错误及处理方法

    1.情况:数据库引擎安装失败,报类似权限不足的错误 解决:可能由于计算机名和用户名相同导致,更改计算机名,卸载干净重装即可

  9. [Mobile] 手机浏览器输入框-数字输入框

    手机浏览器的输入框,一直都是以web的方式进行开发的,没有关注到用户体验,领导提出了输入框要弹出数字输入框,想来应该有这种技术能实现.   搜索之后发现可以使用type="number&qu ...

  10. 求CRC校验和的低位和高位的两种方式

    方式1 unsigned ; // 校验和 ]; memcpy(tstCRCChecksum,&shrCRCCheckSum,); // shrCRCCheckSum:216D LOGI(]) ...