题目大意:有一个生存游戏,里面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. WebMail

    try { WebMail.SmtpServer = "smtp.example.com";      WebMail.SmtpPort = ;      WebMail.Enab ...

  2. 解析 Qt 程序在Windows 下发布

    原文请看:http://www.cnblogs.com/elect-fans/archive/2012/03/15/2408579.html Qt 程序在Windows下发布是本文要介绍的内容,不多说 ...

  3. Bootstrap 实现CRUD示例及代码

    https://github.com/wenzhixin/bootstrap-table-examples/blob/master/crud/index.html <!DOCTYPE html& ...

  4. 【PHPExcel实例】 php 导出 excel 实例

    CREATE TABLE `person` ( `) DEFAULT NULL, `name` ) DEFAULT NULL, `birthday` date DEFAULT NULL ) ENGIN ...

  5. List 集合中 均匀的取七个点 的值

    场景: 一个未知 长度的 List 集合,可能 长度为7,10,50,100, 等等 这个时候 ,我们需要在 集合中 均匀的取七个点: 思路: n=6; int size = list.Size(); ...

  6. hibernate自连接--典型的oracle自带emp实现

    用S2SH三大框架整合,用了oracle自带的表emp,实现了自连接. pojo类: public class Emp implements java.io.Serializable { // Fie ...

  7. 洛谷——P2813 母舰

    P2813 母舰 题目背景 广东汕头聿怀初中 Train#3 Problem 1 (有没有红警既视感~) 题目描述 在小A的星际大战游戏中,一艘强力的母舰往往决定了一场战争的胜负.一艘母舰的攻击力是普 ...

  8. Flask实战第47天:首页导航条首先和代码抽离

    新建一个前台页面的父模板front_base.html 导航条是总boostrap v3中文站拷贝过来的,然后根据自己的需求做一些修改 <!DOCTYPE html> <html l ...

  9. [Atcoder 080] A~D Tutorial

    很好奇这周为什么只有Beginner Contest而没有Regular Contest,本来想着去30minAK的,结果1个小时了还有一道题调不出来o(╯□╰)o A:Parking 让我体验了下开 ...

  10. Codeforces Round #453 ( Div. 2) Editorial ABCD

    A. Visiting a Friend time limit per test 1 second memory limit per test 256 megabytes input standard ...