题意:有 k 只小鸟,每只都只能活一天,但是每只都可以生出一些新的小鸟,生出 i 个小鸟的概率是 Pi,问你 m 天所有的小鸟都死亡的概率是多少。

析:先考虑只有一只小鸟,dp[i] 表示 i 天全部死亡的概率,那么 dpi] = P0 + P1*dp[i-1] + P2*dp[i-1]^2 + ... + Pn*dp[i-1]^(n-1),式子 Pjdp[i-1]^j 表示该小鸟生了 j 后代,,它们在 i-1 天死亡的概率是 dp[i-1],因为有 j 只,每只都是 dp[i-1],所以就是 dp[i-1]^j。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#include <sstream>
#include <list>
#include <assert.h>
#include <bitset>
#include <numeric>
#define debug() puts("++++")
#define gcd(a, b) __gcd(a, b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x)*(x))
#define ms(a,b) memset(a, b, sizeof a)
#define sz size()
#define pu push_up
#define pd push_down
#define cl clear()
#define lowbit(x) -x&x
//#define all 1,n,1
#define FOR(i,x,n) for(int i = (x); i < (n); ++i)
#define freopenr freopen("in.in", "r", stdin)
#define freopenw freopen("out.out", "w", stdout)
using namespace std; typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const LL LNF = 1e17;
const double inf = 1e20;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1000 + 10;
const int maxm = 100 + 2;
const LL mod = 100000000;
const int dr[] = {-1, 1, 0, 0, 1, 1, -1, -1};
const int dc[] = {0, 0, 1, -1, 1, -1, 1, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_in(int r, int c) {
return r >= 0 && r < n && c >= 0 && c < m;
} double p[maxn], dp[maxn]; int main(){
int T, k; cin >> T;
for(int kase = 1; kase <= T; ++kase){
scanf("%d %d %d", &n, &k, &m);
for(int i = 0; i < n; ++i) scanf("%lf", p + i);
dp[0] = 0; dp[1] = p[0];
for(int i = 2; i <= m; ++i){
dp[i] = p[0];
for(int j = 1; j < n; ++j) dp[i] += p[j] * pow(dp[i-1], j);
}
printf("Case #%d: %.6f\n", kase, pow(dp[m], k));
}
return 0;
}

  

UVa 11021 Tribles (概率DP + 组合数学)的更多相关文章

  1. UVA - 11021 Tribles 概率dp

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

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

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

  3. UVA 11021 - Tribles(概率)

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

  4. CF_229E_Gift_概率DP+组合数学

    CF_229E_Gift_概率DP+组合数学 题目描述: 很久很久以前,一位老人和他的妻子住在蔚蓝的海边.有一天,这位老人前去捕鱼,他捉到了一条活着的金鱼.鱼说:“噢,老渔人!我祈求你放我回到海里,这 ...

  5. 概率dp - UVA 11021 Tribles

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

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

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

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

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

  8. UVA - 11021 - Tribles 递推概率

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

  9. UVa 11021 - Tribles

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

随机推荐

  1. 自定义进度条渐变色View

    package com.jianke.stepCounter.Activity; import android.annotation.SuppressLint; import android.cont ...

  2. pyinstller的安装

    下载:http://www.pyinstaller.org/ 解压到目录 切换到python目录 执行命令: python.exe D:\Download\PyInstaller-2.1\setup. ...

  3. SQL Server 数据库备份还原常用SQL语句及注意

    1.备份数据库 backup database db_name to disk='d:\db_name.bak' with format --通过使用with format可以做到覆盖任何现有的备份和 ...

  4. c语言使用指针对int数组的求和

    #include <stdio.h> int sump(int *, int *); int main(void) { , , , , }; printf()); ; } int sump ...

  5. c#tcp源端口号和目的端口怎么理解

    在一台机器上,一个进程对应一个端口.端口的作用就是用来唯一标识这个进程.源端口标识发起通信的那个进程,目的端口标识接受通信的那个进程.有了端口号,接受到报文后才能够知道将报文发送到哪个进程.

  6. Oracle_SQL(3) DML增删改

    sql语言按功能分为:数据定义语言DDL.数据操纵语言DML.数据查询语言DQL.数据控制语言DCL 一.数据操纵语言DML1.insert 新增 语法:insert into <表名> ...

  7. linux 文件搜索

    locate  文件名 在后台数据库中按文件名搜索,搜索速度快,不用遍历整个操作系统 /var/lib/mlocate locate 命令所搜索的后台数据库 updatedb 手动更新数据库 新建的文 ...

  8. Android开发之对ListView的数据进行排序

    这里涉及到对ListView的数据进行排序,以及ListView的数据如何清空处理.排序的方法相同,但是里面的数据集合有些区别:一种是利用pojo类取得数据:另一种是利用map来取得数据. 第一种:利 ...

  9. 5J - 复习时间

    为了能过个好年,xhd开始复习了,于是每天晚上背着书往教室跑.xhd复习有个习惯,在复习完一门课后,他总是挑一门更简单的课进行复习,而他复习这门课的效率为两门课的难度差的平方,而复习第一门课的效率为1 ...

  10. 从matlab中导出下载到的轨迹数据

    我从该网址(http://www.ee.cuhk.edu.hk/~xgwang/MITtrajsingle.html)下载到了一些轨迹数据. 网页中简单说明了轨迹数据的由来:原始数据是在一个停车场上方 ...