https://vjudge.net/contest/361424#problem/H
题意:
有 t只老虎,d只鹿,还有你,每天随机抽两个生物碰面(包括你),现在有以下规则:老虎不管碰到谁都吃掉,同类的话就同归于尽。问人赢得游戏的概率。
题解:
由"If in some day you are sure that you will not be killed, you leave the island immediately and thus win the reality show"可知赢得游戏的条件是要求绝对安全。那什么时候绝对安全呢?不就是老虎都死了的时候嘛。再分析鹿的出现对老虎都死了(最终的绝对安全状态)有影响吗?显然没影响。直接把鹿忽略掉。
人存活下来的唯一方式就是老虎自相残杀。如果老虎由奇数个,那么最后总会留一只老虎,达不到绝对安全状态。偶数个的时候:
对于每一天人活下来的概率 = (两只老虎相遇的情况数)/(人和老虎总共可能相遇的情况数)
t∗ ( t − 1 ) /2 / ( t + 1 ) *t / 2
约分一下
( t − 1 ) ( t + 1 )
每天都减2只老虎,
可列式子:人天天活下来的概率:t-1/t+1 * t-3/t-1 * … * 1/3
通过约分最后剩下的式子就变成了
1/ t + 1
做完了。

#include <bits/stdc++.h>
using namespace std;
int main()
{
   
	int t,cnt=0;
	scanf("%d", &t);
	
	while(t--) {
   
		int n,m;
		scanf("%d%d",&n,&m);
		if(n%2) {
   
			printf("Case %d: 0",++cnt);
		}
		else{
   
			printf("Case %d: %.6f\n",++cnt,1.0/(t+1));
		}
	}
	return 0;
}