HDU1294 rooted Trees problem (integer division combinatorial math DP)

Source: Internet
Author: User
Tags integer division mul

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.