标签:style blog http color os art
题意一直没看懂~~~~不过看懂了之后还是感觉挺好的
#include<cstdio> #include<cstring> #include<algorithm> #define maxn 32 using namespace std; int n; double p[maxn],t; void pre() { p[0]=1; for(int i=1;i<=30;i++) p[i]=p[i-1]*2.0; } double solve() { double f=p[n]; for(int i=n-1;i>=0;i--) { double eq=p[i]/f; if(eq<t) f=(1+t)*f/2.0; else f=(eq-t)*p[i]/(1-t)+(1-eq)*(eq+1)*f/(1-t)/2.0; } return f; } int main() { pre(); while(scanf("%d%lf",&n,&t)&&n) { printf("%.3lf\n",solve()); } return 0; }
标签:style blog http color os art
原文地址:http://www.cnblogs.com/yours1103/p/3854986.html