Test instructions: Given a root tree of n nodes, the sub-nodes of all nodes in each depth are the same. Ask for more trees like this.
Analysis: First this tree is rooted, then there must be a root node, and then the rest of the see can be divided into the same depth of the subtree, that is, it is not the approximate. Then there's the answer,
We just have to calculate how many different trees there are in the n-1, and then we have a recursive type.
The code is as follows:
#pragma COMMENT (linker, "/stack:1024000000,1024000000") #include <cstdio> #include <string> #include < cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set> #include < queue> #include <algorithm> #include <vector> #include <map> #include <cctype> #include < cmath> #include <stack> #define FREOPENR freopen ("In.txt", "R", stdin) #define FREOPENW freopen ("OUT.txt", "W", STDOUT) using namespace Std;typedef long Long ll;typedef pair<int, int> p;const int inf = 0x3f3f3f3f;const double inf = 0x3f3f3f3f3f3f;const LL LNF = 0x3f3f3f3f3f3f;const Double PI = ACOs ( -1.0); const double EPS = 1e-8;const int maxn = 1E3 + 5;const int mod = 1e9 + 7;const int dr[] = {-1, 0, 1, 0};const int dc[] = {0, 1, 0, -1};const char *hex[] = {"0000", "00 "0010", "0011", "0100", "0101", "0110", "0111", "N", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};int N , M;const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, to, 31};const int monn[] = {0, h, H, a, A, a, a, a, a, a, a, a, 31};inline int Min (int a, int b) {return a < b? A:b;} inline int Max (int a, int b) {return a > b a:b;} inline ll Min (ll A, ll b) {return a < b a:b;} inline ll Max (ll A, ll b) {return a > b a:b;} inline bool Is_in (int r, int c) {return R >= 0 && r < n && C >= 0 && C < m;} LL dp[maxn];void init () {dp[1] = 1; DP[2] = 1; for (int i = 2, I < ++i) {for (int j = 1; J <= i; ++j) if (i% j = 0) dp[i+1] = (Dp[i+1] + DP [j])% MoD; }}int Main () {init (); int kase = 0; while (scanf ("%d", &n) = = 1) {printf ("Case%d:%lld\n", ++kase, Dp[n]); } return 0;}
UVa 1645 Count (recursion, number theory)