P3978 [TJOI2015] Probability

Portal

Good God $ rqy $ solution of the problem ....

Total number of binary tree is provided F_n $ $ $ represents n-$ points, $ g_n $ $ F_n $ represents all the leaf nodes of the binary stars

The answer is $ g_n / f_n $, obviously the first $ f_n $ $ Catalan $ columns

Playing table can be found $ g_n = nf_ {n-1} $, proved to be God

Because a binary $ n $ nodes, assuming that there are $ k $ a leaf, then click Delete this $ k $ th leaves will get $ k $ th $ n-1 $ nodes of a binary tree

The fact is that all $ g_n $ $ n $ nodes of a binary tree, remove the leaves and number, equal to the number of binary tree is also deleted after appearing (can be the same)

For a binary n-1 $ $ nodes, it is clear that there must be one and only $ $ n-positions can be linked to the leaf, then remove it from n-$ $ $ The tree nodes to occur when n-1 $ $ node n $ times

So get $ g_n = nf_ {n-1} $

Then a wave of formula can get the answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
typedef long double ldb;
inline int read()
{
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
    return x*f;
}
ldb n;
int main()
{
    n=read();
    printf("%.12Lf\n",n*(n+1)/(2*(2*n-1)));
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/LLTYYC/p/11361626.html
Recommended