Tribles(概率)

时间:2021-12-29 13:39:49
Description
 

Problem A
Tribbles
Input: Standard Input

Output: Standard Output

GRAVITATIONn.
"The tendency of all bodies to approach one another with a strength
proportion to the quantity of matter they contain -- the quantity of
matter they contain being ascertained by the strength of their tendency
to approach one another. This is a lovely and edifying illustration of
how science, having made A the proof of B, makes B the proof of A."

Ambrose Bierce

You have a population of kTribbles. This particular species of Tribbles live for exactly one day and then die. Just before death, a single Tribble has the probability Pi of giving birth to i more Tribbles. What is the probability that after m generations, everyTribble will be dead?

Input
The first line of input gives the number of cases, NN test cases follow. Each one starts with a line containing n (1<= n<=1000) ,k (0<= k<=1000) and m (0<= m<=1000) . The next n lines will give the probabilities P0P1, ...,Pn-1.

Output
For each test case, output one line containing "Case #x:" followed by the answer, correct up to an absolute or relative error of 10-6.

Sample Input

Sample Output

4 
3 1 1
0.33 
0.34 
0.33 
3 1 2 
0.33 
0.34 
0.33 
3 1 2 
0.5 
0.0 
0.5 
4 2 2
0.5 
0.0 
0.0 
0.5
Case #1: 0.3300000 
Case #2: 0.4781370 
Case #3: 0.6250000 
Case #4: 0.3164062 

 

题意:有K只麻球,每只只活一天,临死前会产仔,产i只小麻球的 概率为pi,问m天后所有麻球全部死亡的概率;

思路:因为每只麻球都是相互独立的,所以只需求刚开始只有一只麻球,m天后其后代全部死亡的概率f[m],然后k只麻球最后全部死亡的概率就是 pow(f[m],k);

对于一只麻球,m天全死亡包含第一天、第二天、、、、、第m天死亡事件,因此一只麻球第i天死亡的概率f[i] = p0 + p1*f[i-1] + p2*f[i-2]^2+.......+ pn-1*f[i-1]^(n-1);

 #include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
int test;
scanf("%d",&test);
for(int item = ; item <= test; item++)
{
int n,k,m;
double p[],f[];
scanf("%d %d %d",&n,&k,&m);
for(int i = ; i < n; i++)
scanf("%lf",&p[i]); f[] = ;
f[] = p[];
for(int i = ; i <= m; i++)
{
f[i] = ;
for(int j = ; j < n; j++)
f[i] += p[j] * pow(f[i-],j);
}
printf("Case #%d: %.7lf\n",item,pow(f[m],k));
}
return ;
}

Tribles(概率)的更多相关文章

  1. UVA - 11021 Tribles 概率dp

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

  2. UVA 11021 - Tribles&lpar;概率递推&rpar;

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

  3. UVA 11021 - Tribles&lpar;概率&rpar;

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

  4. UVa 11021 Tribles &lpar;概率DP &plus; 组合数学&rpar;

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

  5. UVA11021 Tribles 概率dp

    题目传送门 题意:开始有$k$只兔子,每只都是活一天就死,每只死前都会有$pi$的概率生出$i$只兔子.求$m$天后兔子死光的概率. 思路: 设$f[i]$为一只兔子在第i天死完的概率,那么答案就是$ ...

  6. UVA 11021 C - Tribles&lpar;概率DP&rpar;

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

  7. UVA11021 Tribles&lbrack;离散概率 DP&rsqb;

    UVA - 11021 Tribles GRAVITATION, n. “The tendency of all bodies to approach one another with a stren ...

  8. uva11021 - Tribles(概率)

    11021 - Tribles GRAVITATION, n.“The tendency of all bodies to approach one another with a strengthpr ...

  9. 概率dp - UVA 11021 Tribles

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

随机推荐

  1. docker通过iptables修改或新增镜像映射端口

    443 8088 22 端口是初始映射端口 [root@SERVER ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAM ...

  2. JSHelper时间格式化

    Helper.prototype.FormatDate = function (format) { var _now = new Date(); var o = { "M+": _ ...

  3. Android Studio Gradle Build Running 特别慢的问题探讨

    本文的本本win7 64bit 6G android studio2.1 在运行程序的时候Gradle Build Running 特别慢,一个helloworld都快2min了 1.开启gradle ...

  4. ASP&period;NET MVC中,怎么使用jquery&sol;ajaxForm上传文件

    ajaxForm插件最好选择:jquery forms plugin. 以下为示例: Ajax.BeginForm @using (Ajax.BeginForm("YourAction&qu ...

  5. SQL Server 监控 使用sp&lowbar;trace&lowbar;create

    监控前言 上一节我们提到了MSSQL的基于SQL Event的监控,但是有些时候我们需要更加详细.适用于调优排错的监控.SQL Server内部运行的可见性是的查询调整.优化和综合排查成为可能!这一节 ...

  6. http&colon;&sol;&sol;venkatbaggu&period;com&sol;file-upload-in-asp-net-mvc-using-dropzone-js-and-html5&sol;

    http://venkatbaggu.com/file-upload-in-asp-net-mvc-using-dropzone-js-and-html5/ http://www.cnblogs.co ...

  7. 非常好用的正则表达式&quot&semi;&bsol;&bsol;s&plus;&quot&semi; - 匹配任意空白字符

    说起来,博主使用过的正则场景虽然不多,但是就是在这当中,我发现"\\s+"真好用! 详解 "\\s+" 正则表达式中\s匹配任何空白字符,包括空格.制表符.换页 ...

  8. linux之SQL语句简明教程---UPDATE DELETE FROM

    我们有时候可能会需要修改表格中的资料.在这个时候,我们就需要用到 UPDATE 指令.这个指令的语法是: UPDATE "表格名" SET "栏位1" = [新 ...

  9. Django 个性化管理员站点

    from django.contrib import admin # Register your models here. from .models import Moment class Momen ...

  10. web应用&sol;路由控制&sol;视图函数&sol;单表多表操作

    一. 1.wen应用:BS架构的应用程序,B是浏览器,S:server(实现了wsgi协议)+ application https://www.cnblogs.com/liuqingzheng/art ...