http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1962

f(i) 表示 在有一只tribble 经过i天后全死掉的 概率

然后枚举tribble第一天生了多少个后代 所以:

f(i) = P0*(f(i-1)^0)+P1*(f(i-1)^1)+P2*(f(i-1)^2)+.......+Pn-1*(f(i-1)^n-1)

代码:

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<vector>
#include<algorithm>
#include<queue> #define ull unsigned long long
#define ll long long
#define lint long long
using namespace std; const int INF=0x3f3f3f3f;
const int N=1003;
double p[N],f[N];
int main()
{
//freopen("data.in","r",stdin);
int T;
scanf("%d",&T);
for(int c=1;c<=T;++c)
{
printf("Case #%d: ",c);
int n,k,m;
scanf("%d %d %d",&n,&k,&m);
for(int i=0;i<n;++i)
scanf("%lf",&p[i]);
for(int i=0;i<=m;++i)
f[i]=0;
for(int i=1;i<=m;++i)
{
for(int j=0;j<n;++j)
f[i]+=(p[j]*pow(f[i-1],j));
}
printf("%.7lf\n",pow(f[m],k));
}
return 0;
}

UVa 11021 - Tribles的更多相关文章

  1. UVA 11021 - Tribles(概率递推)

    UVA 11021 - Tribles 题目链接 题意:k个毛球,每一个毛球死后会产生i个毛球的概率为pi.问m天后,全部毛球都死亡的概率 思路:f[i]为一个毛球第i天死亡的概率.那么 f(i)=p ...

  2. UVA 11021 - Tribles(概率)

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=481&page=s ...

  3. UVA - 11021 Tribles 概率dp

    题目链接: http://vjudge.net/problem/UVA-11021 Tribles Time Limit: 3000MS 题意 有k只麻球,每只活一天就会死亡,临死之前可能会出生一些新 ...

  4. 概率dp - UVA 11021 Tribles

    Tribles Problem's Link: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=33059 Mean: 有k个细 ...

  5. UVA 11021 Tribles(递推+概率)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=33059 [思路] 递推+概率. 设f[i]表示一只Tribble经 ...

  6. UVa 11021 Tribles (概率DP + 组合数学)

    题意:有 k 只小鸟,每只都只能活一天,但是每只都可以生出一些新的小鸟,生出 i 个小鸟的概率是 Pi,问你 m 天所有的小鸟都死亡的概率是多少. 析:先考虑只有一只小鸟,dp[i] 表示 i 天全部 ...

  7. UVA - 11021 - Tribles 递推概率

    GRAVITATION, n.“The tendency of all bodies to approach one another with a strengthproportion to the ...

  8. UVA 11021 C - Tribles(概率DP)

    记忆化就可以搞定,比赛里都没做出来,真的是态度有问题啊... #include <iostream> #include<cstdio> #include<cstring& ...

  9. UVa 11021 (概率 递推) Tribles

    Tribble是麻球? 因为事件都是互相独立的,所以只考虑一只麻球. 设f(i)表示一只麻球i天后它以及后代全部死亡的概率,根据全概率公式: f(i) = P0 + P1 * f(i-1) + P2 ...

随机推荐

  1. python 在不同层级目录import 模块的方法

    有一个文件夹/home/a,  里面有个模块叫b.py,  我怎么把他import到程序里? 1). import sys; sys.path.append("/home/a/") ...

  2. [mysql]支持emoji(字符集问题)!

    问题的根源 主要问题就是在字符集,一般解决这种问题都是靠试验.我实验了一通,得出的结论和大家分享一下(如有错误,还望指正): 数据库的字符集 数据库连接的字符集 配置方法 设置数据库的字符集为utf8 ...

  3. samba服务器常用指令

    samba服务器需要安装samba.samba-common.samba-client三个包: samba -----samba服务器程序的所有文件 samba-common -----提供了Samb ...

  4. python网络编程socket之多线程

    #coding:utf-8 __author__ = 'similarface' import os,socket,threading,SocketServer SERVER_HOST='localh ...

  5. matlab cross 3*1 向量叉乘

    一定是1*3  或者3*1 的向量才可以叉乘 A=[1 2 3] B=[4 5 6] cross(A,B) ans=[-3 6 -3] 解决机器人微分运动量之间的等价关系

  6. [C:\Users\Administrator\.IntelliJIdea2016.1\system\tomcat\Unnamed_demo_2\work\Catalina\localhost\demo\org\apache\jsp\index_jsp.java]

    http://www.oschina.net/question/1444338_2146454?sort=time

  7. PacBio长reads的大基因组组装

    原文链接:Large Genome Assembly with PacBio Long Reads 可以以多种方式利用PacBio长reads来生成和改进大型基因组的de novo组装. 你可以用几种 ...

  8. IIS 安装 pydio

    Introduction In this how-to, we’ll see the installation of Pydio (Put Your Data In Orbit), which is ...

  9. each用法

    1.数组用法 <script> var s=["s","i","l","e","n",& ...

  10. 创建高性能移动 web 站点

    如果你的网站3秒钟没有响应,人们就会失去兴趣了.为了满足响应快这个愿望,需要一个不同的方法在手机上进行分析,设计和测试. 这篇文章将会对Johan Johansson在2013年4月提出" ...