explanation See http://www.cnblogs.com/IMGavin/p/5621370.html, 4 can be re-assembled
The number of nodes of the DFS enumeration subtree, multiplied and accumulated
1#include <iostream>
2#include <cstdio>
3#include <cstring>
4#include <cstdlib>
5#include <algorithm>
6usingnamespaceStd
7typedefLongLongLL;
8
9LL f[ A];
Tenll cm (ll N, ll m) {
Onem = min (n-m, M);
ALL ans =1;
- for(LL i =1; I <= m; i++) {
-Ans = ans * (n-m + i)/I;
the}
- returnAns
-}
-
+
-voidDfsintNintXintR, LL mul) {
+if(r = =0){
AF[n] + = Mul;
at
-}Else{
- for(inti = x; I < n; i++) {
- for(intj =1; I * j <= R; J + +) {
-DFS (n, i +1, R-i * J, Mul * cm (F[i] + J-1, j));
-}
in}
-
to}
+}
-intMain () {
theMemset (F,0,sizeof(f));
*f[1] =1; f[2] =1;
$ for(inti =3; I <= +; i++) {
Panax NotoginsengDFS (I,1I1,1);
-}
the
+intN
A while(~SCANF ("%d", &n)) {
theprintf"%i64d\n", F[n]);
+
-}
$return0; $ }
HDU1294 rooted Trees problem (integer division combinatorial math DP)