UVA 10900 So you want to be a 2n-aire?
2014-09-16 00:02
351 查看
参考
http://www.cnblogs.com/staginner/archive/2011/12/13/2286691.html
http://www.cnblogs.com/staginner/archive/2011/12/13/2286691.html
#include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <stack> #include <queue> #include <cctype> #include <cstdio> #include <string> #include <vector> #include <climits> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> #define LL long long #define PI 3.1415926535897932626 using namespace std; int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);} #define MAXN 35 double v[MAXN],ans,T; int N; int main() { v[0]=1; for (int i=1;i<=30;i++) v[i]=v[i-1]*2; while (scanf("%d%lf",&N,&T)!=EOF) { if (N==0 && T==0) break; if (fabs(1-T)<1e-9) {printf("%.3lf\n",v );continue;} double ans=v ; for (int i=N-1;i>=0;i--) { double f=v[i]/ans; if (f<=T) ans=(1+T)/2*ans; else ans=(f-T)/(1-T)*v[i]+(1-f)/(1-T)*(1+f)/2*ans; } printf("%.3lf\n",ans); } return 0; }
相关文章推荐
- UVA 10900 - So you want to be a 2n-aire?(概率)
- UVA 10900 So you want to be a 2n-aire?
- UVA 10900 So you want to be a 2n-aire? 2元富翁 (数学期望,贪心)
- UVa10900 - So you want to be a 2n-aire? (期望)
- uva10900 - So you want to be a 2n-aire? 概率 递推
- UVa 10900 So you want to be a 2n-aire?
- UVa 10900 - So you want to be a 2n-aire?
- So you want to be a 2n-aire? UVA - 10900
- UVa 10900 So you want to be a 2n-aire? (概率DP,数学)
- UVa 10900 - So you want to be a 2n-aire? 期望
- 【概率】Uva 10900 - So you want to be a 2n-aire?
- UVa 10900 (连续概率、递推) So you want to be a 2n-aire?
- 概率dp - Uva 10900 So you want to be a 2n-aire?
- UVA - 10900 So you want to be a 2n-aire?(连续概率)
- uva 10900 - So you want to be a 2n-aire?(期望)
- UVA 10900 So you want to be a 2n-aire? (概率dp)
- uva 10090 So you want to be a 2n-aire?
- HDOJ 1145 So you want to be a 2n-aire? 期望DP
- UVA 10900 So you want to be a 2n-aire?
- hdu 1145 So you want to be a 2n-aire?