题目大意:有一个生存游戏,里面t仅仅老虎,d仅仅鹿,另一个人,每天都要有两个生物碰面,如今有下面规则

1.老虎和老虎碰面。两仅仅老虎就会同归于尽

2.老虎和人碰面或者和鹿碰面,老虎都会吃掉对方

3.人和鹿碰面。人能够选择吃或者不吃该鹿

4.鹿和鹿碰面,相安无事

问人存活下来的概率

解题思路:自己想复杂了。用了二维的dp。。。

看了别人的,发现根本不用dp,人生存下来的条件就是不被老虎吃掉,所以仅仅要全部的老虎都同归于尽了,人就能够生存下来了

假设老虎的数量是奇数,那么人总有一天会被吃掉的

假设老虎的数量是偶数,那就算一下全部老虎同归于尽的概率。这个概率就是人存活下来的概率了

鹿能够忽略不计,刚開始还以为须要。。

。在时间无限的情况下。老虎没死光的话,鹿总有一天是会被全部吃掉的

#include<cstdio>
#define maxn 1010
double dp[maxn][maxn], ans;
int n, t, d;
void solve() {
ans = 1.0;
while(t) {
ans *= 1.0 * (t - 1) / (t + 1);
t -= 2;
}
} int main() {
int test, cas = 1;
scanf("%d", &test);
while(test--) {
scanf("%d%d", &t, &d);
printf("Case %d: ", cas++);
if(t == 0) {
printf("1.0000000\n");
continue;
}
if(t % 2) {
printf("0.0000000\n");
continue;
}
solve();
printf("%.7lf\n", ans);
}
return 0;
}

LightOJ - 1265 Island of Survival 期望的更多相关文章

  1. LightOJ - 1265 Island of Survival —— 概率

    题目链接:https://vjudge.net/problem/LightOJ-1265 1265 - Island of Survival    PDF (English) Statistics F ...

  2. [LightOJ 1265] Island of Survival

    Island of Survival You are in a reality show, and the show is way too real that they threw into an i ...

  3. LightOj 1265 - Island of Survival(概率)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1265 题目大意:有一个生存游戏,里面t只老虎,d只鹿,还有一个人,每天都要有两个生物碰 ...

  4. LightOJ.1265.Island of Survival(概率)

    题目链接...我找不着了 \(Description\) 岛上有t只老虎,1个人,d只鹿.每天随机有两个动物见面 1.老虎和老虎碰面,两只老虎就会同归于尽: 2.老虎和人碰面或者和鹿碰面,老虎都会吃掉 ...

  5. LightOJ - 1265 Island of Survival (概率dp)

    You are in a reality show, and the show is way too real that they threw into an island. Only two kin ...

  6. LightOJ 1065 Island of Survival (概率DP?)

    题意:有 t 只老虎,d只鹿,还有一个人,每天都要有两个生物碰面,1.老虎和老虎碰面,两只老虎就会同归于尽 2.老虎和人碰面或者和鹿碰面,老虎都会吃掉对方 3.人和鹿碰面,人可以选择杀或者不杀该鹿4. ...

  7. LightOj:1265-Island of Survival

    Island of Survival Time Limit: 2 second(s) Memory Limit: 32 MB Program Description You are in a real ...

  8. LightOJ 1030 Discovering Gold(期望)

    Description You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell o ...

  9. LightOj:1030-Discovering Gold(期望dp模板)

    传送门:http://www.lightoj.com/volume_showproblem.php?problem=1030 Discovering Gold Time Limit: 2 second ...

随机推荐

  1. poj 1182 (扩展并查集)

    食物链 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 58979   Accepted: 17247 Description ...

  2. AC日记——背单词 洛谷 P2353

    背单词 思路: KMP+统计前缀和优化: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 1000005 ], ...

  3. section

    @RenderSection("Header")   @section Header { <div class="view"> @foreach ( ...

  4. 其实参与QtCreator开发也很容易

    http://bbs.csdn.net/topics/370241186 10个月前发过一个组建Qt团队,共同研究.学习.完善QtCreator的帖子,不过在为QtCreator提交完一个补丁后,就没 ...

  5. Shiro的认证原理(Subject#login的背后故事)

    登录操作一般都是我们触发的: Subject subject = SecurityUtils.getSubject(); AuthenticationToken authenticationToken ...

  6. Spring源码分析之Bean的加载流程

    spring版本为4.3.6.RELEASE 不管是xml方式配置bean还是基于注解的形式,最终都会调用AbstractApplicationContext的refresh方法: @Override ...

  7. 1.L 查询关键字 HEXLOC

    Take the compile listing for the program that has either OFFSET or LIST option selected. Use the OFF ...

  8. Jenkins实现CI(Continuous Integration)到CD(Continuous Delivery)

    Pipeline as Code是2.0的精髓所在,是帮助Jenkins实现CI(Continuous Integration)到CD(Continuous Delivery)华丽转身的关键推手.所谓 ...

  9. HTTP Slow Attack测试工具SlowHTTPTest

    HTTP Slow Attack测试工具SlowHTTPTest   Slow Attack是HTTP常见的一种拒绝服务攻击方式.它通过消耗服务器的系统资源和连接数,导致Web服务器无法正常工作.常见 ...

  10. 【bzoj2190】[SDOI2008]仪仗队 数论 欧拉函数 筛法

    http://www.lydsy.com/JudgeOnline/problem.php?id=2190   裸欧拉函数,先不计算对角线(a,a)的一列,然后算出1到n-1的所有欧拉函数相加*2,再加 ...