Test instructions
How many n nodes have a root tree, which satisfies the same number of child nodes per layer of nodes, and outputs that number divided by the remainder of 1e9+7.
Analysis:
This kind of topic belongs to the kind, looks very high cold, reads the question to be higher cold. Think of N long think not come out, a search problem, lying trough, so SB's question I will not.
To the point, according to test instructions, this tree is about the root node symmetry, symmetry is very good, the root node below the subtree is identical.
So there is the following recursive relationship:
1#include <cstdio>2#include <cmath>3 4 Const intMAXN = +;5 Const intMOD =1000000000+7;6 intANS[MAXN +Ten];7 8 voidInit ()9 {Tenans[1] =1; One for(inti =2; I <= MAXN; ++i) A { - intm =sqrt (i); - for(intj =1; J <= M; ++J)if((I-1)% J = =0) the { - if(J * j = i-1) Ans[i] = (Ans[i] + ans[j])%MOD; - ElseAns[i] = ((((Ans[i] + ans[j])%mod) + ans[(i-1)/j])%MOD; - } + } - } + A intMain () at { - Init (); - intKase =0, N; - while(SCANF ("%d", &n) = =1) -printf"Case %d:%d\n", ++Kase, Ans[n]); - in return 0; -}
code June
UVa 1645 (Recursive) Count