BZOJ 4001[TJOI2015]概率论
2015-09-28 11:11
260 查看
4001: [TJOI2015]概率论
Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 583 Solved: 294
[Submit][Status][Discuss]
Description
Input
输入一个正整数N,代表有根树的结点数Output
输出这棵树期望的叶子节点数。要求误差小于1e-9Sample Input
1Sample Output
1.000000000HINT
1<=N<=10^9解题思路:
手动推了前5个,发现规律 ans = n * (n + 1) / 2 / (2 * n - 1);
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define LL long long
using namespace std;
const int MAXN = 1000 + 10;
double N;
int main()
{
scanf("%lf", &N);
double ans = (N * (N + 1)) / 2.0 / (2.0 * N - 1.0);
printf("%.9lf\n", ans);
return 0;
}
相关文章推荐
- linux下如何配置SQLSERVER ODBC
- MPLS调试笔记之FP用法
- Swift中闭包(closure)的使用
- An internal error occurred during: "Validating **".问题处理
- Nitrate XML-RPC Service API
- 灰度线性变换
- Mysql主从复制原理
- Android签名打包出现Export aborted because fatal lint errors were found的解决
- Swift - 使用MapKit显示地图,并在地图上做标记
- SecureCRT配置显示的字符集
- java定时器
- CheckBox滑动后乱序
- C数据结构学习历程(1) 顺序表
- Unity3D-个人学习的道路
- 在ROS 使用摄像头 WebCam 完成图像处理(2) -- 初探OpenCV
- Swift - 经纬度位置坐标与真实地理位置相互转化
- 文章标题
- 获取confirm返回值的故事
- adsl模拟拨号
- C++ std::vector : 用法与技巧