题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4472

Problem Description
Prof. Tigris is the head of an archaeological team who is currently in charge of an excavation in a site of ancient relics.

This site contains relics of a village where civilization once flourished. One night, examining a writing record, you find some text meaningful to you. It reads as follows.

“Our village is of glory and harmony. Our relationships are constructed in such a way that everyone except the village headman has exactly one direct boss and nobody will be the boss of himself, the boss of boss of himself, etc. Everyone expect the headman
is considered as his boss’s subordinate. We call it relationship configuration. The village headman is at level 0, his subordinates are at level 1, and his subordinates’ subordinates are at level 2, etc. Our relationship configuration is harmonious because
all people at same level have the same number of subordinates. Therefore our relationship is …”

The record ends here. Prof. Tigris now wonder how many different harmonious relationship configurations can exist. He only cares about the holistic shape of configuration, so two configurations are considered identical if and only if there’s a bijection of
n people that transforms one configuration into another one.

Please see the illustrations below for explanation when n = 2 and n = 4.




The result might be very large, so you should take module operation with modules 109 +7 before print your answer.
 
Input
There are several test cases.

For each test case there is a single line containing only one integer n (1 ≤ n ≤ 1000).

Input is terminated by EOF.
 
Output
For each test case, output one line “Case X: Y” where X is the test case number (starting from 1) and Y is the desired answer.
 
Sample Input
1
2
3
40
50
600
700
 
Sample Output
Case 1: 1
Case 2: 1
Case 3: 2
Case 4: 924
Case 5: 1998
Case 6: 315478277
Case 7: 825219749
 
Source

题意:

有n个点,使之构成一个树。要求每一层的每一个节点的子节点数要同样。问有多少中构造法!

PS:

对于n个点,先将第一个节点(父节点)去掉。由于父节点仅仅有一个,还剩下
n-1 个点,

由于每一层的每一个节点的子节点数要同样,所以将这
n-1 个节点m等分,每份为(n-1)/m个点,

再递归求解就可以。

代码例如以下:

#include <cstdio>
#include <cstring>
#define mod 1000000007
int dp[1017];
void init()
{
dp[1] = 1;
dp[2] = 1;
dp[3] = 2;
for(int i = 4; i <= 1000; i++)
{
for(int j = 1; j < i; j++)
{
if((i-1)%j == 0)
{
dp[i]+=dp[(i-1)/j];
dp[i] %= mod;
}
}
}
}
int main()
{
int n;
int cas = 0;
init();
while(~scanf("%d",&n))
{
printf("Case %d: %d\n",++cas,dp[n]);
}
return 0;
}

HDU 4472 Count(数学 递归)的更多相关文章

  1. hdu 4472 Count(递推即dp)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4472 代码: #include <cstdio> #include <cstring ...

  2. hdu 4472 Count (递推)

    Count Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  3. hdu 4472 Count

    递推,一般的dp值: #include<stdio.h> #include<string.h> #define mod 1000000007 ]; int Dp() { a[] ...

  4. hdu 4472 Count (2012 ACM-ICPC 成都现场赛)

    递推,考虑到一n可以由i * j + 1组合出来,即第二层有j个含有i个元素的子树...然后就可以了.. #include<algorithm> #include<iostream& ...

  5. [dp] hdu 4472 Count

    意甲冠军: 鉴于n节点,满足子节点的相同的树节点号的同一层较少不同的形式. 思考: dp[i][j] 代表i节点.最后,一个层j方法节点 由于满足同层节点,所以j一层又一层必须是j 整数倍 所以就能得 ...

  6. HDU 4472 Count DP题

    解题报告:题目大意,给你n个球,要将这n个球从下到上按层次排列,要求同一个层次的的每一个分支的数量都必须相等,问有多少种排列的方法. 此题的一个DP题,假设现在有n个球,要将这n个球排列好,我们就必须 ...

  7. HDU 4472 Count (DP)

    题目:问n个节点构成完全对称的树有多少种方法. 因为树是完全对称的,所以它的子树也是完全对称的. 对于每个树,拿出一个根节点,枚举剩下的节点能拆分成多少个子树. #include <cstdio ...

  8. HDU 4588 Count The Carries 数学

    Count The CarriesTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  9. HDU 4588 Count The Carries (数学,计数)

    题意:给定两个十进制数,求二进制中,从x加到y的二进制进了多少位. 析:把这些数字的二进制纵向罗列出来,然后一位一位的把和加起来,最终得到总的进位数.从1到x,第i位上1的总数是x左移i+1位再右移i ...

随机推荐

  1. Oracle锦集

    1:将数组转成datatable SELECT COLUMN_VALUE FROM TABLE(CAST(UTIL.INTONUMBERTABLE(REPLACE(NVL(V_CATEGORY_ID, ...

  2. Windows10更新后,远程桌面无法登录服务器 提示远程桌面协议 CredSSP 出现漏洞

    Win10远程桌面 出现 身份验证错误,要求的函数不受支持,这可能是由于CredSSP加密Oracle修正 解决方法 打开注册表,手动建立 这个路径 HKEY_LOCAL_MACHINE\SOFTWA ...

  3. 数据库分库分表中间件:Mycat;分布式数据库;mysql的分布式事务

    官网:http://mycat.io/,里面有电子书籍可以下载:http://www.mycat.io/document/mycat-definitive-guide.pdf 旧版本下载地址:http ...

  4. 奇怪吸引子---Chua

    奇怪吸引子是混沌学的重要组成理论,用于演化过程的终极状态,具有如下特征:终极性.稳定性.吸引性.吸引子是一个数学概念,描写运动的收敛类型.它是指这样的一个集合,当时间趋于无穷大时,在任何一个有界集上出 ...

  5. js中document.write的那点事

    document.write()方法可以用在两个方面:页面载入过程中用实时脚本创建页面内容,以及用延时脚本创建本窗口或新窗口的内容.该方法需要一个字符串参数,它是写到窗口或框架中的HTML内容.这些字 ...

  6. php随机生成汉字实现方法

    GB 2312-80 是中国国家标准简体中文字符集,全称<信息交换用汉字编码字符集·基本集>,由中国国家标准总局发布,1981年5月1日实施.GB2312 编码通行于中国大陆:新加坡等地也 ...

  7. PHP 使用PHPExcel删除Excel单元格指定列

    需求是这样的: 有一个系统仅公司内部和外部经销商使用,在一个导出功能中公司内部员工跟外部经销商导出的列是不一样的(某些数据是不能提供给经销商的) 因为导出的数据都是一样的(某些列外数据外部没有)因此并 ...

  8. (转)Unity3D中脚本的执行顺序和编译顺序(vs工程引用关系)

    自:http://www.cnblogs.com/champ/p/execorder.html 在Unity中可以同时创建很多脚本,并且可以分别绑定到不同的游戏对象上,它们各自都在自己的生命周期中运行 ...

  9. Python编译exe

    有几种办法,选择py2exe,从pip安装,还不行,下载看起来都比较老,还是在csdn上下载了一个64位版本for2.7的 http://download.csdn.net/download/henu ...

  10. A Complete ActiveX Web Control Tutorial

    A Complete ActiveX Web Control Tutorial From: https://www.codeproject.com/Articles/14533/A-Complete- ...