hdu 5984
Pocky
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2095 Accepted Submission(s): 1133
Problem Description
Let’s talking about something of eating a pocky. Here is a Decorer Pocky, with colorful decorative stripes in the coating, of length L.
While the length of remaining pocky is longer than d, we perform the following procedure. We break the pocky at any point on it in an equal possibility and this will divide the remaining pocky into two parts. Take the left part and eat it. When it is not longer than d, we do not repeat this procedure.
Now we want to know the expected number of times we should repeat the procedure above. Round it to 6 decimal places behind the decimal point.
Input
The first line of input contains an integer N which is the number of test cases. Each of the N lines contains two float-numbers L and d respectively with at most 5 decimal places behind the decimal point where 1 ≤ d, L ≤ 150.
Output
For each test case, output the expected number of times rounded to 6 decimal places behind the decimal point in a line.
Sample Input
6
1.0 1.0
2.0 1.0
4.0 1.0
8.0 1.0
16.0 1.0
7.00 3.00
Sample Output
0.000000
1.693147
2.386294
3.079442
3.772589
1.847298
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
double l,d;
scanf("%d",&t);
while(t--){
scanf("%lf%lf",&l,&d);
if(l<=d){
printf("0.000000\n");
}
else{
printf("%.6f\n",+log(l/d));
}
}
return ;
}
hdu 5984的更多相关文章
- HDU 5984.Pocky(2016 CCPC 青岛 C)
Pocky Let’s talking about something of eating a pocky. Here is a Decorer Pocky, with colorful decora ...
- HDU 5984 数学期望
对长为L的棒子随机取一点分割两部分,抛弃左边一部分,重复过程,直到长度小于d,问操作次数的期望. 区域赛的题,比较基础的概率论,我记得教材上有道很像的题,对1/len积分,$ln(L)-ln(d)+1 ...
- HDU 5984(求木棒切割期望 数学)
题意是给定一长为 L 的木棒,每次任意切去一部分直到剩余部分的长度不超过 D,求切割次数的期望. 若木棒初始长度不超过 D,则期望是 0.000000: 设切割长度为 X 的木棒切割次数的期望是 F( ...
- HDU 5984 题解 数学推导 期望
Let’s talking about something of eating a pocky. Here is a Decorer Pocky, with colorful decorative s ...
- 2016 ACM/ICPC亚洲区青岛站现场赛(部分题解)
摘要 本文主要列举并求解了2016 ACM/ICPC亚洲区青岛站现场赛的部分真题,着重介绍了各个题目的解题思路,结合详细的AC代码,意在熟悉青岛赛区的出题策略,以备战2018青岛站现场赛. HDU 5 ...
- 【数学期望】hdu5984 Pocky
http://www.oyohyee.com/post/HDU/5984.html 看这篇吧,懒得写了. 训练时推得的式子有点鬼畜. #include<cstdio> #include&l ...
- hdu5984概率数学
转载 https://www.oyohyee.com/post/HDU/5984.html
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
随机推荐
- Spark Mllib里决策树回归分析使用.rootMeanSquaredError方法计算出以RMSE来评估模型的准确率(图文详解)
不多说,直接上干货! Spark Mllib里决策树二元分类使用.areaUnderROC方法计算出以AUC来评估模型的准确率和决策树多元分类使用.precision方法以precision来评估模型 ...
- ci框架数据库相关函数
返回查询影响的记录数 $res = $this->db->get_where('wx_life',array('id'=>$id)); $num = $res->num_row ...
- c#ADSL拨号类
class ADSLHelper { /// <summary> ///拨号 /// </summary> /// <param name="connectio ...
- Thread 和 Runnable创建新线程的区别,Runnable可以共享线程类的实例属性
Thread实现多线程: public class Thread2 extends Thread{ public int i; public void run(){ for(; i < 100 ...
- bootstrap fileinput 上传文件
最近用到文件上传功能, 说实话:以前遇到过一次,COPY了别人的代码 结束! 这次又要用,可是看到别人很酷的文件上传功能,心痒了! 好吧.简单的办法,找控件: bootstrap fileinput ...
- CSS布局技巧之——各种居中
居中是我们使用css来布局时常遇到的情况.使用css来进行居中时,有时一个属性就能搞定,有时则需要一定的技巧才能兼容到所有浏览器,本文就居中的一些常用方法做个简单的介绍. 注:本文所讲方法除了特别说明 ...
- -oN ,-oX,-oG
-oN ,正常输出 -oX, xml输出 nmap 192.168.9.12 -oX TEST.xml -oG grep输出 html文件可读性比xml文件要好,将xml转换成html xs ...
- 如何变更站点 AD 域服务器IP地址
在 winserver 2012 单森林单域,多站点环境中,想把某一个站点AD 域服务器IP地址更改,要如何操作,才能保证客户端正常运行,不影响客户端的运行.有些朋友也经常提出类似问题. 想在不影响 ...
- LoadRunner使用(2)
一.基础函数 在VU左边导航栏中,有三个LoadRunner框架函数,分别是Vuser_init(),Action(),vuser_end().这三个函数存在于任何Vuser类型的脚本中. vuser ...
- checkbox 全选 单选的使用
绑定数据 if (!IsPostBack) { using (UsersDataContext con = new UsersDataContext()) { Repeater1.DataSource ...