Island of Survival 概率

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int t,n,d;

int main()
{
	scanf("%d",&t);
	int cas=1;
	while(t--)
	{
		scanf("%d%d",&n,&d);
		printf("Case %d: ",cas++);
		if(n%2){
			puts("0.000000");
		}
		else {
		printf("%.6lf\n",1.0/(n+1));
		}
	}
}

  这题,这么看,他说要求那个人存活的概率,后来看了题解才知道自己完全想歪了。

那个deer根本没用。因为他和你会不会被吃毫无关系,此时我们之前用的求概率的公式完全不顶用了,什么递推方程也不要去想他。

这里只要这么想。老虎有什么可能都会有存活呢:奇数个。那么人必死。

另一种情况就是一个人和n个老虎有一个活1/(n+1)的概率把人挑出来,然后让老虎自相残杀。

时间: 2024-07-30 19:10:21

Island of Survival 概率的相关文章

LightOJ 1265 Island of Survival 概率DP

H - Island of Survival Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1265 Description You are in a reality show, and the show is way too real that they threw into an island. Only two kinds o

LightOJ 1065 Island of Survival (概率DP?)

题意:有 t 只老虎,d只鹿,还有一个人,每天都要有两个生物碰面,1.老虎和老虎碰面,两只老虎就会同归于尽 2.老虎和人碰面或者和鹿碰面,老虎都会吃掉对方 3.人和鹿碰面,人可以选择杀或者不杀该鹿4.鹿和鹿碰面,没事问人存活下来的概率 析:最后存活肯定是老虎没了,首先可以用概率dp来解决,dp[i][j] 表示 还剩下 i 考虑, j 只鹿存活的概率是多少. 然后每次分析这几种情况即可. 还有一种思路就是只要考虑老虎没了,只要老虎没了就能存活,只要计算老虎全死完的概率就好,首先如果老虎是奇数,是

light oj 1265 - Island of Survival(概率dp)

1265 - Island of Survival PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB You are in a reality show, and the show is way too real that they threw into an island. Only two kinds of animals are in the island, the tigers and t

LightOJ 1268 Island of Survival 数学神解/不用写那些guapi概率dp

谢谢Wen_kr的翻译 题目大意: 你困在一个岛上,上面有老虎和鹿,分别有 只与 只. 如果有一天,你和老虎相遇,那么你死,你和鹿相遇,那么你可以选择杀死或者不杀死这头鹿,老虎和鹿相遇,那么鹿死,鹿和鹿相遇,什么也不会发生,老虎与老虎相遇,那么它们会杀死对方. 每天仅能有一对动物相遇,问你不死并且所有老虎死掉的最大概率. 第一种解法:概率dp 设dp[i][j]为i头老虎j头鹿满足条件的概率...... 这个解法不重要,重要的是下一个. 第二种解法:数学贪心 尽量让老虎自相残杀 即当前老虎为t,

LightOJ1265---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 kinds of animals are in the island, the tigers and the deer. Though unfortunate but the truth is that, each day exactly two animals meet each other. So,

LightOJ - 1265 Island of Survival 期望

题目大意:有一个生存游戏,里面t只老虎,d只鹿,还有一个人,每天都要有两个生物碰面,现在有以下规则 1.老虎和老虎碰面,两只老虎就会同归于尽 2.老虎和人碰面或者和鹿碰面,老虎都会吃掉对方 3.人和鹿碰面,人可以选择吃或者不吃该鹿 4.鹿和鹿碰面,相安无事 问人存活下来的概率 解题思路:自己想复杂了,用了二维的dp... 看了别人的,发现根本不用dp,人生存下来的条件就是不被老虎吃掉,所以只要所有的老虎都同归于尽了,人就可以生存下来了 如果老虎的数量是奇数,那么人总有一天会被吃掉的 如果老虎的数

Codeforces Round #301 (Div. 2) -- (A,B,C,D)

题目传送:Codeforces Round #301 (Div. 2) A. Combination Lock 水题,求最小移动次数,简单贪心一下即可 AC代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <cmath> #include <queue> #include <stack> #i

[Codeforces Round #301 (Div. 2) D]Bad Luck Island(概率Dp)

Description The Bad Luck Island is inhabited by three kinds of species: r rocks, s scissors and p papers. At some moments of time two random individuals meet (all pairs of individuals can meet equiprobably), and if they belong to different species, t

Codeforces Round #301 (Div. 2) D. Bad Luck Island 概率DP

D. Bad Luck Island The Bad Luck Island is inhabited by three kinds of species: r rocks, s scissors and p papers. At some moments of time two random individuals meet (all pairs of individuals can meet equiprobably), and if they belong to different spe