题目链接

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

  1. #include <cstdio>
  2. #include <iostream>
  3. #include <cmath>
  4. using namespace std;
  5. #define LL __int64
  6. LL dp[][][];
  7. LL c[][];
  8. int main()
  9. {
  10. int i,j,n,k,u,h;
  11. for(i = ; i <= ; i ++)
  12. {
  13. c[i][] = ;
  14. }
  15. for(i = ; i <= ; i ++)
  16. {
  17. for(j = ; j <= ; j ++)
  18. c[i][j] = c[i-][j-] + c[i-][j];
  19. }
  20. dp[][][] = ;
  21. scanf("%d%d",&n,&h);
  22. for(i = ; i < n; i ++)
  23. {
  24. for(j = ; j <= n; j ++)
  25. {
  26. for(k = ; k <= n; k ++)
  27. {
  28. if(dp[i][j][k] == ) continue;
  29. for(u = ; u <= *k; u ++)
  30. dp[i+][j+u][u] += c[*k][u]*dp[i][j][k];
  31. }
  32. }
  33. }
  34. LL ans = ;
  35. for(i = h; i <= n; i ++)
  36. {
  37. for(k = ; k <= n; k ++)
  38. {
  39. ans += dp[i][n][k];
  40. }
  41. }
  42. printf("%I64d\n",ans);
  43. return ;
  44. }

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. 在ubuntu上搭建开发环境6---安装和使用vim及其插件(Pathogen和NERDTree)

    2015.09.08 更为详细的配置vim的方法,请参见我的新整理的文章:http://segmentfault.com/a/1190000003722928 Vim安装 命令: sudo apt-g ...

  2. 【翻译十九】-java之执行器

    Executors In all of the previous examples, there's a close connection between the task being done by ...

  3. poj 1007:DNA Sorting(水题,字符串逆序数排序)

    DNA Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 80832   Accepted: 32533 Des ...

  4. windows操作技巧

    -------------------win7专有------------------- WIN+上下左右可以将当前窗口 最大化.左侧放置.右侧放置.最小化 WIN+Shift+左右是让窗口在多个屏幕 ...

  5. 【计算机图形学】openGL常用函数

    OpenGL常用函数   glAccum 操作累加缓冲区   glAddSwapHintRectWIN 定义一组被 SwapBuffers拷贝的三角形   glAlphaFunc允许设置alpha检测 ...

  6. hibernate中many-to-one关联时出现ObjectNotFoundException异常

    采用多对一关联,如果一的那端删除了,多的这端无法感知,虽然数据库中可以通过外键配置将多的一端置空,可是在hibernate里面我暂时不知道如何处理. 目前采用的方式: 1.首先,数据库中需要配置好外键 ...

  7. java 杂物间 (一) Mybatis

    这里放置的是一些杂物,生人勿入. Token的一般parse 过程. @Test public void shouldDemonstrateGenericTokenReplacement() { Ge ...

  8. NS2中修改载波侦听范围和传输范围

    修改这两个值是在tcl中进行的,加上 Phy/WirelessPhy set CSThresh_ 1.559e-11 ;#550m Phy/WirelessPhy set RXThresh_ 3.65 ...

  9. 同一天的时间差,显示为HHMMSS和指定日期时间部分

    //1.hhmmss private String setGoodsDisBalance(Date startTime,Date endTime){ //时间差:毫秒ms long diff = en ...

  10. Reading and Writing CSV Files in C#

    Introduction A common requirement is to have applications share data with other programs. Although t ...