HDU 4472 Count (线性dp 推公式)
来源:互联网 发布:泳衣 知乎 编辑:程序博客网 时间:2024/05/22 13:34
Count
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1631 Accepted Submission(s): 1028
Total Submission(s): 1631 Accepted Submission(s): 1028
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.
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.
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
1234050600700
Sample Output
Case 1: 1Case 2: 1Case 3: 2Case 4: 924Case 5: 1998Case 6: 315478277Case 7: 825219749
Source
2012 Asia Chengdu Regional Contest
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4472
题目大意 :给n个点构成一棵树,要求每层的每个节点的子节点数目相同
题目分析 :用dp[i]表示节点个数为i的方法数,一个节点作为根的时候剩下的i-1个节点进行均分,分成j份所以当(i-1) % j == 0时 dp[i] += dp[j],
这就是这道题的动规方程。最后注意取模
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4472
题目大意 :给n个点构成一棵树,要求每层的每个节点的子节点数目相同
题目分析 :用dp[i]表示节点个数为i的方法数,一个节点作为根的时候剩下的i-1个节点进行均分,分成j份所以当(i-1) % j == 0时 dp[i] += dp[j],
这就是这道题的动规方程。最后注意取模
#include <cstdio>int const MAX = 1e3 + 5;int const MOD = 1e9 + 7;int dp[MAX];int main(){ dp[1] = 1; for(int i = 1; i <= 1000; i++) for(int j = 1; j < i; j++) if((i - 1) % j == 0) dp[i] += dp[j] % MOD; int n, ca = 1; while(scanf("%d", &n) != EOF) printf("Case %d: %d\n", ca++, dp[n] % MOD);}
0 0
- HDU 4472 Count (线性dp 推公式)
- hdu 4472 Count DP 递推
- hdu 2064 汉诺塔III(推公式+dp)
- hdu 2077 汉诺塔IV(推公式+dp)
- hdu 1995 汉诺塔V(推公式+dp)
- HDU 4472 Count 递推
- hdu 4472 Count 递推
- 【线性递推DP】hdu 5550
- POJ 1958 Strange Towers of Hanoi (线性dp 推公式)
- hdu 4472 Count dp
- [dp] hdu 4472 Count
- hdu 2050 折线分割平面 #DP#递推公式
- hdu 4472 Count (递推)
- HDU 4472 count(递推)
- hdu 4472 Count(简单递推)
- HDU-#4472 Count(DP)
- HDU 4472 - Count(计数DP)
- HDU ACM 4472 Count->DP
- poj1185 状态压缩Dp
- 用快速排序的思想求第K大的数或最大的k个数
- VS2010字符串相加的问题
- android调试
- Axure
- HDU 4472 Count (线性dp 推公式)
- 二分|hash(找正方形)poj2002
- Ubuntu关闭小键盘
- Android控件源码分析--AndroidResideMenu菜单
- UVA 839 - Not so Mobile
- NGUI官网示例2-interaction-讲解(一)
- 简单理解javascript中的原型对象,实现对之间共享属性和行为
- HDU 2955解题报告
- 【BZOJ3631】[JLOI2014]松鼠的新家 树链剖分