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

    #include<bits/stdc++.h>
    #include<stdio.h>
    #include<iostream>
    #include<cmath>
    #include<math.h>
    #include<queue>
    #include<set>
    #include<map>
    #include<iomanip>
    #include<algorithm>
    #include<stack>
    #define inf 0x3f3f3f3f
    using namespace std;
    typedef long long ll;
    double t;int n;
    double ans;
    ll mypow(int a,int b)
    {
        ll res=1;
        while(b--)res*=a;
        return res;
    }
    double f[33];
    int main()
    {
    #ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
    #endif // ONLIN
        double p0,p1;
        while(cin>>n>>t)
        {
            if(n==0)break;
            f[n]=1.0*mypow(2,n);
            for(int i=n-1;i>=0;i--)
            {
                p0=max(t,1.0*mypow(2,i)/f[i+1]);
                p1=(p0-t)/(1-t);
                f[i]=mypow(2,i)*p1+(1+p0)/2*f[i+1]*(1-p1);
            }
            printf("%.3f
    ",f[0]);
        }
    }
  • 相关阅读:
    stack 栈
    链表
    2018.09.08 DL24 Day1 总结
    10.07 WZZX Day2总结
    10.06 WZZX Day1总结
    Joseph问题 (线段树)
    [POI2006]TET-Tetris 3D
    10.05FZSZ Day2模拟总结
    Tarjan求LCA
    数据结构
  • 原文地址:https://www.cnblogs.com/linruier/p/9532567.html
Copyright © 2011-2022 走看看