zoukankan      html  css  js  c++  java
  • UVA 10900 So you want to be a 2n-aire?

    参考

    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
    ",v[N]);continue;}
            double ans=v[N];
            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
    ",ans);
        }
        return 0;
    }
    今年输的,明年全都要赢回来
  • 相关阅读:
    CG_Lession
    linux学习网站大全[转]
    C++ books
    Linux 建议学习路径[转]
    talking C++ STL
    Factory
    计算机图像图形学相关好书推荐
    ASP.NET控件缩写大全
    web开发面试题一
    ASP.Net面试题之二
  • 原文地址:https://www.cnblogs.com/Commence/p/3974027.html
Copyright © 2011-2022 走看看