[原创]LIGHTOJ 1265 - Island of Survival [递推|概率dp]【杂类|动态规划】

2017-01-12 15:48:15 Tabris_ 阅读数：326

https://blog.csdn.net/qq_33184171/article/details/54378682

--------------------------------------------------------------------------------.
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 the deer. Though unfortunate but the truth is that, each day exactly two animals meet each other. So, the outcomes are one of the following

a) If you and a tiger meet, the tiger will surely kill you.
b) If a tiger and a deer meet, the tiger will eat the deer.
c) If two deer meet, nothing happens.
d) If you meet a deer, you may or may not kill the deer (depends on you).
e) If two tigers meet, they will fight each other till death. So, both will be killed.

If in some day you are sure that you will not be killed, you leave the island immediately and thus win the reality show. And you can assume that two animals in each day are chosen uniformly at random from the set of living creatures in the island (including you).

Now you want to find the expected probability of you winning the game. Since in outcome (d), you can make your own decision, you want to maximize the probability.

Input
Input starts with an integer T (≤ 200), denoting the number of test cases.

Each case starts with a line containing two integers t (0 ≤ t ≤ 1000) and d (0 ≤ d ≤ 1000) where t denotes the number of tigers and d denotes the number of deer.

Output
For each case, print the case number and the expected probability. Errors less than 10-6 will be ignored.

Sample Input

4
0 0
1 7
2 0
0 10

Output for Sample Input

Case 1: 1
Case 2: 0
Case 3: 0.3333333333
Case 4: 1

--------------------------------------------------------------------------------.

1.鹿的存在对人能不能活下来是没有影响的。——所以考虑d的值没有任何意义
2.只有老虎全部死亡，人才能活下来。——又因为老虎只能两两自相残杀，所以只有t为偶数的时候人才有活下来的概率。

$\frac{\frac{t*(t-1)}{2} }{\frac{t*(t+1)}{2} }$

$\frac{(t-1)}{(t+1)}$

$\frac{(t-1)}{(t+1)}*\frac{((t-2)-1)}{((t-2)+1)}*...*\frac{(2-1)}{(2+1)}$

$\frac{1}{t+1}$

==================分割线==================

-------------------------------.