[TJOI2015] Probability theory - Catalan number

A randomly generated \ (n-\) desired root nodes of the binary tree (the probability of a different configuration from each other and all forms of occurrence) of the leaf nodes. \ (n \ leq 10 ^ 9 \)

Solution

\ (n-\) number, i.e. the number of binary dots Catalan \ (F (n-) = \ {C_ {FRAC 2N}} ^ {n-n-+. 1} \)

Set \ (g (n) \) of \ (n-\) number of leaves of a binary tree of all points and, to find the law to give \ (g (n) = nf (n-1) \)

Proof. For \ (n-\) points, \ (K \) th binary tree leaves, the leaves can be deleted any \ (K \) a \ (n-1 \) binary points, each of these binary there \ (n-\) positions may be linked to a new leaf

To ask
\ [\ frac {g_n} { f_n} = \ frac {nf_ {n-1}} {f_n} = \ frac {n (n + 1)} {2 (2n-1)} \]

#include <bits/stdc++.h>
using namespace std;
double n;
signed main() {
    cin>>n;
    printf("%.10lf\n",n*(n+1)/2/(2*n-1));
}

Guess you like

Origin www.cnblogs.com/mollnn/p/12363942.html
Recommended