LightOJ - 1265 Island of Survival 期望
题目大意:有一个生存游戏,里面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 期望的更多相关文章
- LightOJ - 1265 Island of Survival —— 概率
题目链接:https://vjudge.net/problem/LightOJ-1265 1265 - Island of Survival PDF (English) Statistics F ...
- [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 ...
- LightOj 1265 - Island of Survival(概率)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1265 题目大意:有一个生存游戏,里面t只老虎,d只鹿,还有一个人,每天都要有两个生物碰 ...
- LightOJ.1265.Island of Survival(概率)
题目链接...我找不着了 \(Description\) 岛上有t只老虎,1个人,d只鹿.每天随机有两个动物见面 1.老虎和老虎碰面,两只老虎就会同归于尽: 2.老虎和人碰面或者和鹿碰面,老虎都会吃掉 ...
- 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 ...
- LightOJ 1065 Island of Survival (概率DP?)
题意:有 t 只老虎,d只鹿,还有一个人,每天都要有两个生物碰面,1.老虎和老虎碰面,两只老虎就会同归于尽 2.老虎和人碰面或者和鹿碰面,老虎都会吃掉对方 3.人和鹿碰面,人可以选择杀或者不杀该鹿4. ...
- LightOj:1265-Island of Survival
Island of Survival Time Limit: 2 second(s) Memory Limit: 32 MB Program Description You are in a real ...
- 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 ...
- LightOj:1030-Discovering Gold(期望dp模板)
传送门:http://www.lightoj.com/volume_showproblem.php?problem=1030 Discovering Gold Time Limit: 2 second ...
随机推荐
- gulp配合vue压缩代码格式化
实际项目就是一个单页面.因此,我觉得用gulp足够,并且不需要webpack和vue-cli因为没有必要使用组件. 先来说一下项目结构 1. 然后来看看我的包管理package.json都用了啥,你也 ...
- GIT的安装及git状态的变更详解
一.安装git环境 (2)Git安装 Centos: yum install -y git Ubuntu: apt-get install git Windows安装git bash软件 注意不要使用 ...
- mysql ERROR 1366
mysql ERROR 1366 mysql> INSERT INTO tb_room VALUES ('9101','9','1',300,'9101',0,1,'超级豪华间','public ...
- windows 安装tp5 composer方式
1.下载windows composer-setup.exe(我已下载一个Composer-Setup.exe); 2.我电脑使用的是phpstudy2018版 php-7.0.12-NTS 3.然后 ...
- bss、data、text、heap(堆)与stack(栈)
bss段: bss段(bss segment)通常是指用来存放程序中未初始化的全局变量和静态变量(static)的一块内存区域. bss是英文Block Started by Symbol的简称. b ...
- css文本、字母、数字过长 自动换行处理
---恢复内容开始--- white-space: normal|pre|nowrap|pre-wrap|pre-line|inherit;white-space 属性设置如何处理元素内的空白norm ...
- NestedScrollView
参考文章: Android滑动到顶部悬停 NestedScrollView的使用 效果图: 实现步骤: 将需要悬浮的layout放到CollapsingToolbarLayout之外,AppBarLa ...
- Eclipse内嵌的webservice客户端
概述 Eclipse内嵌的webservice客户端,可用于发起请求,查看结果,展示请求和响应的报文. 详情 在Java EE视图,可以看到内嵌的webservice客户端浏览器登陆按钮 点击打开浏览 ...
- Codeforces Round #426 (Div. 2) D The Bakery(线段树 DP)
The Bakery time limit per test 2.5 seconds memory limit per test 256 megabytes input standard input ...
- Xamarin.Forms教程下载安装JDK配置环境变量
Xamarin.Forms教程下载安装JDK配置环境变量 Xamarin.Form环境配置下载安装JDK JDK是编程Java程序必须的软件.也许有人会问我们用的C#为什么还有Java呢?这是因为我们 ...