【数学期望】hdu5984 Pocky

http://www.oyohyee.com/post/HDU/5984.html

看这篇吧,懒得写了。

训练时推得的式子有点鬼畜。

#include<cstdio>
#include<cmath>
using namespace std;
int n;
double d,L;
int main(){
//	freopen("c.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%lf%lf",&L,&d);
		if(L-d<0.00000001){
			printf("%.6lf
",0.0);
			continue;
		}
		L/=d;
		d/=d;
		printf("%.6lf
",((1.0/d-log(d))*L+L*log(L))/L);
	}
	return 0;
}
原文地址:https://www.cnblogs.com/autsky-jadek/p/6682770.html