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. org.apache.jasper.JasperException: Expecting "jsp:param" standard action with "name" and "value" attributes

      jasper  英 ['dʒæspə]  美 ['dʒæspɚ] 跟读 口语练习 n. 碧玉:墨绿色 n. (Jasper)人名:(德)雅斯佩尔:(西)哈斯佩尔 JasperException 异 ...

  2. MyBatis学习笔记(三) 关联关系

    首先给大家推荐几个网页: http://blog.csdn.net/isea533/article/category/2092001 没事看看 - MyBatis工具:www.mybatis.tk h ...

  3. for( unsigned int i=heapSize/2-1; i>=0; --i)

    unsigned int的表示 今天在写堆排序的时候遇到一个BUG void builMaxHeap( int *arr,unsigned int heapSize){ unsigned int i; ...

  4. iOS设置app应用程序文件共享

    1.iOSapp应用程序文件共享 当我们用itnues连接到设备时,在应用程序栏目下面,文件共享下,点击 对应的程序,即可以在程序右边栏目里面看到应用程序共享的数据, 此时,我们可以通过右下角的 添加 ...

  5. 使用Objective-C的文档生成工具

    前言 做项目的人多了,就需要文档了.今天开始尝试写一些项目文档.但是就源代码来说,文档最好和源码在一起,这样更新起来更加方便和顺手.象Java语言本身就自带javadoc命令,可以从源码中抽取文档.今 ...

  6. 能源项目xml文件 -- app-init.xml

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  7. navigator.userAgent.indexOf来判断浏览器类型

    navigator.userAgent.indexOf来判断浏览器类型 (2011-03-03 11:30:40) 转载▼ 标签: 杂谈   来源:http://xtaai5233.blog.163. ...

  8. WAMP 403 Forbidden禁止访问 的解决办法

    修改httpd.conf文件 # onlineoffline tag - don't remove Require local To # onlineoffline tag - don't remov ...

  9. [redis] Jedis 与 ShardedJedis 设计

    Jedis设计 Jedis作为推荐的java语言redis客户端,其抽象封装为三部分: 对象池设计:Pool,JedisPool,GenericObjectPool,BasePoolableObjec ...

  10. python 第三方模块 转 https://github.com/masterpy/zwpy_lst

    Chardet,字符编码探测器,可以自动检测文本.网页.xml的编码. colorama,主要用来给文本添加各种颜色,并且非常简单易用. Prettytable,主要用于在终端或浏览器端构建格式化的输 ...