码迷,mamicode.com
首页 > 其他好文 > 详细

bzoj4001 [TJOI2015]概率论

时间:2017-12-31 20:58:09      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:inline   esc   desc   概率   using   www.   ++   div   com   

Description

技术分享图片

Input

输入一个正整数N,代表有根树的结点数

Output

 输出这棵树期望的叶子节点数。要求误差小于1e-9

Sample Input

1

Sample Output

1.000000000

HINT

 1<=N<=10^9

 

正解:期望。

首先可以打表找规律得到代码里的式子。

然后证明的话,不是很会,可以看看这篇博客:Miskcoo‘s Space

 1 #include <bits/stdc++.h>
 2 #define il inline
 3 #define RG register
 4 #define ll long long
 5 
 6 using namespace std;
 7 
 8 int main(){
 9 #ifndef ONLINE_JUDGE
10   freopen("probability.in","r",stdin);
11   freopen("probability.out","w",stdout);
12 #endif
13   int n; cin>>n;
14   printf("%0.12lf\n",0.5*n*(n+1)/(2*n-1));
15   return 0;
16 }

 

bzoj4001 [TJOI2015]概率论

标签:inline   esc   desc   概率   using   www.   ++   div   com   

原文地址:https://www.cnblogs.com/wfj2048/p/8030084.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!