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, then one individual kills the other one: a rock kills scissors, scissors kill paper, and paper kills a rock. Your task is to determine for each species what is the probability that this species will be the only one to inhabit this island after a long enough period of time.
The single line contains three integers r, s and p (1?≤?r,?s,?p?≤?100) ― the original number of individuals in the species of rock, scissors and paper, respectively.
Print three space-separated real numbers: the probabilities, at which the rocks, the scissors and the paper will be the only surviving species, respectively. The answer will be considered correct if the relative or absolute error of each number doesn't exceed 10?-?9.
鏈接:http://codeforces.com/contest/540/problem/D
題意:1個(gè)島上有石頭人,剪刀人,布人,每天會(huì)有兩個(gè)人相遇,根據(jù)相克會(huì)死掉1個(gè)人。問(wèn)最后只剩下石頭人的概率,只剩剪刀人的概率,布人的概率。
做法:dp[i][j][k] 代表有i個(gè)石頭,j個(gè)剪刀,k個(gè)布的概率。
以剪刀和布相遇為例,會(huì)有轉(zhuǎn)移 dp[i][j][k⑴]+=dp[i][j][k]*j*k/(i+j+k)/(i+j+k⑴) 。
但是這是不夠的,由于還有平局的情況。平局的時(shí)候,狀態(tài)又轉(zhuǎn)移回了dp[i][j][k],又從原狀態(tài)開(kāi)始轉(zhuǎn)移,所以轉(zhuǎn)移的比例還是1樣的。
所以可以直接把 所有的轉(zhuǎn)移概率相加,然后在轉(zhuǎn)移的時(shí)候除掉。轉(zhuǎn)移方程變成dp[i][j][k⑴]+=dp[i][j][k]*j*k/(i+j+k)/(i+j+k⑴)/tem;
tem為不是平局的概率總和。