hdu 4472动规水题
挺水的动态规划,只要依次枚举子树的个数即可。
/* * hdu4472/win.cpp * Created on: 2012-11-17 * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <ctime> #include <iostream> #include <algorithm> #include <queue> #include <set> #include <map> #include <stack> #include <string> #include <vector> #include <deque> #include <list> #include <functional> #include <numeric> #include <cctype> using namespace std; const int MAXN = 1005; const int MOD = 1000000007; long long dp[MAXN]; int main() { #ifndef ONLINE_JUDGE freopen("data.in", "r", stdin); #endif int t = 1, n; dp[1] = 1; for(int i = 2; i <= 1000; i++) { dp[i] = 0; for(int j = 1; j < i; j++) { if((i - 1) % j == 0) { dp[i] += dp[(i - 1) / j]; dp[i] %= MOD; } } } while(scanf("%d", &n) == 1) { printf("Case %d: %d\n", t++, (int)dp[n]); } return 0; }