HDU-4472-Count (2012 ACM/ICPC成都现场赛)

Count

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 1850    Accepted Submission(s): 1200

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

2012 Asia Chengdu Regional Contest

题意:去找有多少种树,使得同一层的节点的度要一致

思路:简单DP

AC代码:

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int dp[1010] = {0,1,1,2,3};
const int maxn = 1000000007;

void init()
{
	for(int i=5; i<=1000; i++)
	{
		for(int j=1; j<i; j++)
		{
			if((i-1)%j==0)
			{
				dp[i] += dp[j];
				dp[i] %= maxn;
			}
		}
	}
} 

int main()
{
	init();
	int n, k=1;
	while(~scanf("%d", &n))
	{
		printf("Case %d: %d\n", k, dp[n]);
		k++;
	}
	return 0;
}
时间: 2024-12-09 08:16:01

HDU-4472-Count (2012 ACM/ICPC成都现场赛)的相关文章

HDU-4464-Browsing History (2012 ACM/ICPC成都现场赛!)

Browsing History Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3065    Accepted Submission(s): 1692 Problem Description One day when you are going to clear all your browsing history, you come

2013 ACM/ICPC 长沙现场赛 A题 - Alice&#39;s Print Service (ZOJ 3726)

Alice's Print Service Time Limit: 2 Seconds      Memory Limit: 65536 KB Alice is providing print service, while the pricing doesn't seem to be reasonable, so people using her print service found some tricks to save money. For example, the price when

HDU 4292 FOOD 2012 ACM/ICPC Asia Regional Chengdu Online

Food Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3399    Accepted Submission(s): 1141 Problem Description You, a part-time dining service worker in your college’s dining hall, are now confus

hdu 4435 第37届ACM/ICPC天津现场赛E题

转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlove 题目:给出N个城市,从1开始需要遍历所有点,选择一些点建立加油站,使得花费最少 这题的特殊性在于他的花费上,2^(i-1) 利用一个非常重要的性质,2^0+2^1+2^2……+2^i<2^(i+1) 所有编号<=i的所有点都建,总花费比建一个还少. 这里就贪心一下,先假设所有点都建,然后依次从编号大的删点,看看能不能遍历整个图 dist[i]表示

hdu 4432 第37届ACM/ICPC天津现场赛B题

题目大意就是找出n的约数,然后把约数在m进制下展开,各个数位的每一位平方求和,然后按m进制输出. 模拟即可 1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<cstring> 5 #include<cmath> 6 #include<queue> 7 #include<map> 8 using namespace std; 9

2013 ACM/ICPC 长沙现场赛 C题 - Collision (ZOJ 3728)

Collision Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge There's a round medal fixed on an ideal smooth table, Fancy is trying to throw some coins and make them slip towards the medal to collide. There's also a round range which

hdu 4465 Candy 2012 成都现场赛

1 /** 2 对于大数的很好的应用,,缩小放大,,保持精度 3 **/ 4 #include <iostream> 5 #include <cmath> 6 #include <algorithm> 7 #include <cstdio> 8 using namespace std; 9 10 int main() 11 { 12 double n,p; 13 int cnt =1; 14 while(cin>>n>>p){ 15

Go Deeper(2010成都现场赛题)(2-sat)

G - Go Deeper Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Description Here is a procedure's pseudocode: go(int dep, int n, int m) begin output the value of dep. if dep < m and x[a[dep]] + x[b[dep]] != c[dep] then go(dep +

Error Curves(2010成都现场赛题)

F - Error Curves Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Description Josephina is a clever girl and addicted to Machine Learning recently. She pays much attention to a method called Linear Discriminant Analysis, which h