zoukankan      html  css  js  c++  java
  • UVA11021 Tribles

    UVA11021 Tribles

    Solution

    说是全概率公式推导出来个

    大体理解下, 首先假设 f[i - 1] 已知嘛
    那他可以从多少种情况转移过来咧

    一共不是死一只、两只。。。n - 1只嘛
    所以它其实是用第一个状态推过来的, 第一个生一只, 死完的概率是 f[i - 1]
    两只是 f[i - 1] ^ 2
    就这么推出来了

    Code

    #include<iostream>
    #include<cstdio>
    #include<queue>
    #include<cstring>
    #include<algorithm>
    #include<climits>
    #include<cmath>
    #define LL long long
    #define REP(i, x, y) for(int i = (x);i <= (y);i++)
    using namespace std;
    int RD(){
        int out = 0,flag = 1;char c = getchar();
        while(c < '0' || c >'9'){if(c == '-')flag = -1;c = getchar();}
        while(c >= '0' && c <= '9'){out = out * 10 + c - '0';c = getchar();}
        return flag * out;
        }
    const int maxn = 1010;
    int T, num, k, m, Tony;
    double p[maxn];
    double dp[maxn];
    void init(){
    	num = RD(), k = RD(), m = RD();
    	REP(i, 0, num - 1)cin>>p[i];
    	dp[1] = p[0];
    	}
    void work(){
    	REP(i, 2, m){
    		double res = 1;
    		dp[i] = 0;
    		REP(j, 0, num - 1){
    			dp[i] += res * p[j];
    			res *= dp[i - 1];
    			}
    		}
    	printf("Case #%d: %.7f
    ", ++Tony, pow(dp[m], k));
    	}
    int main(){
    	T = RD();
    	while(T--){
    		init();
    		work();
    		}
    	return 0;
    	}
    
  • 相关阅读:
    CentOS6.5升级内核到3.10.28的记录
    redis集群搭建,手把手教学
    zookeeper集群搭建,这一篇就够了
    Caused by: java.sql.SQLException: Column 'show_type' not found
    zkEnv.sh: Syntax error: "(" unexpected (expecting "fi")记录一下解决方法。。。
    http分层
    浏览器
    less
    333
    CSS 解决方案
  • 原文地址:https://www.cnblogs.com/Tony-Double-Sky/p/14599379.html
Copyright © 2011-2022 走看看