多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > php教程 > light oj 1265 - Island of Survival(概率dp)

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

來源:程序員人生   發布時間:2015-05-08 08:27:36 閱讀次數:3155次

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 will be ignored.

Sample Input

Output for Sample Input

4

0 0

1 7

2 0

0 10

Case 1: 1

Case 2: 0

Case 3: 0.3333333333

Case 4: 1

 


SPECIAL THANKS: JANE ALAM JAN (DESCRIPTION, SOLUTION, DATASET)

思路:疏忽deer的影響,每次乘以都是老虎相遇的幾率


#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include<queue> #include<stack> #include<vector> #include<set> #include<map> #define L(x) (x<<1) #define R(x) (x<<1|1) #define MID(x,y) ((x+y)>>1) #define eps 1e⑻ //typedef __int64 ll; #define fre(i,a,b) for(i = a; i <b; i++) #define free(i,b,a) for(i = b; i >= a;i--) #define mem(t, v) memset ((t) , v, sizeof(t)) #define ssf(n) scanf("%s", n) #define sf(n) scanf("%d", &n) #define sff(a,b) scanf("%d %d", &a, &b) #define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c) #define pf printf #define bug pf("Hi ") using namespace std; #define INF 0x3f3f3f3f #define N 10005 int tiger,deer; int main() { int i,j,t,ca=0; sf(t); while(t--) { scanf("%d%d",&tiger,&deer); printf("Case %d: ",++ca); double ans=1; if(tiger&1) { printf("0.00000000 "); continue; } while(tiger>0) { ans*=tiger*(tiger⑴)*1.0/(tiger*(tiger+1)); tiger-=2; } printf("%.7lf ",ans); } return 0; }







生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 国产精品一区久久精品 | 亚欧美色 | www在线视频| 麻豆亚洲精品一区二区 | 黑人性xxxⅹxxbbbbb | 午夜羞羞 | www.xxxx欧美| 一级做a爰片性色毛片黄书 一级做a爰片性色毛片男 | 精品福利国产 | 手机看片福利永久 | 最近中文免费高清字幕 | 国产精品成人观看视频网站 | 精品一区二区三区在线视频 | 国产成人精品视频 | 国产三级视频 | purnhurb国产在线观看 | 色爱区综合| 男女激情动态视频 | 亚洲春色综合另类小说 | 精品国产免费一区二区三区 | 一区二区三区四区五区 | 地址一地址二地址三 | 自拍视频啪 | 欧美性小说 | 午夜影院在线看 | 久久久久久久国产 | 亚洲激情专区 | 亚洲国产精品嫩草影院久久 | 亚洲国产天堂久久综合 | 国产一起色一起爱 | 日本xxxx色视频在线观看免 | 日本三区视频 | 最新jizz欧美| 国内自拍小视频 | 综合亚洲一区二区三区 | 中文乱码字字幕在线第5页 中文欧美日韩 | 日韩欧美亚洲一区精选 | xxxxx日本护士xxxhd | 日本免费网站视频www区 | freexxxx呦女| 国产福利自产拍在线观看 |