挺水的动态规划,只要依次枚举子树的个数即可。

/*
 * 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;
}

相关文章:

  • 2021-11-16
  • 2021-12-06
  • 2021-10-27
  • 2021-05-29
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-19
  • 2021-09-03
  • 2021-12-24
  • 2021-10-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案