Count(poj4472 )dp
来源:互联网 发布:红旗linux系统 编辑:程序博客网 时间:2024/06/09 06:19
Count
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2079 Accepted Submission(s): 1367
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
简单的dp ,仔细推敲一下即可
#include <iostream>#include <stdio.h>#include <cmath>#include <cstring>using namespace std;long long a[1001][1001];int eps=pow(10,9)+7;int main(){ memset(a,0,sizeof(a));int n;a[1][0]=1;a[1][1]=1;for(int i=2;i<1001;i++){for(int j=1;j<i;j++) a[i][j]=1; for(int j=2;j<=i/2;j++){ for(int k=1;k<i/j;k++){ a[i][j*k]+=a[i-j*k][j]; } }}int s=1;while(cin>>n){long long sum=0;for(int i=0;i<n;i++) {sum+=a[n][i]; // cout<<a[n][i]<<" "; }//cout<<endl;printf("Case %d: %d\n",s++,sum%eps);}return 0;}
0 0
- Count(poj4472 )dp
- HDU-#4472 Count(DP)
- HDU 3485 Count 101(简单DP)
- hdu3336 Count the string(dp)
- UVA 10007Count the Trees (dp)
- LightOj 1122 Digit Count(数位dp)
- hdu3336 Count the string(kmp+dp)
- count 数字计数 (数位dp)
- 【DP】Order Count
- hdu4472 Count(简单dp)
- hdu 4472 Count dp
- [dp] hdu 4472 Count
- hdu4472 Count dp
- HDU4472 Count DP
- uva 1645 Count dp
- hdu 3336 Count the string(KMP+dp)
- hdu 3336 Count the string (DP+kmp)
- hdu 3336 count the string(KMP+dp)
- UVA_11636_HelloWorld!
- Java实现了任意位置截屏(仿QQ截图)
- iOS开发 main.m
- Java之Object.WAIT()
- 树状数组 离散化 求逆序数POJ 2299Ultra-QuickSort解题报告
- Count(poj4472 )dp
- 如何成为社会精英
- [持续更新]HTML5学习笔记(四)
- 解决ViewPager.setCurrentItem不能实现平滑移动
- Android UI之最优ListView写法
- 初学python,模拟转账
- get、put、post、delete含义与区别
- android__常见布局
- Android接口回调,最简单的理解方式