http://acm.hdu.edu.cn/showproblem.php?pid=5984
给定一个 长度为l的木板,每次等概率的在其中任意一个点切割,然后拿掉左半边,然后如果剩下的长度不大于d,就结束切割,否则继续切割。
问你 切割数目的期望。。
具体的公式推倒。
https://www.oyohyee.com/post/HDU/5984.html
考虑到
ln(2)=0.693147.
直接写
#include <bits/stdc++.h>
using namespace std;
const int maxn=200;
double a,b;
int main()
{ int m;
scanf("%d",&m);
while(m--){
scanf("%lf%lf",&a,&b);
if(a<=b)//小于的情况。
puts("0.000000");
else
printf("%.6f\n",log((a/b))+1);
//puts("0.000000");
}
return 0;
}