Codeforces Round #301 (Div. 2) D. Bad Luck-island probability DP

Source: Internet
Author: User

D. Bad Luck

The bad Luck are inhabited by three kinds of species: R Rocks, s scissors and p papers. At some moments of time both random individuals meet (all pairs of individuals can meet equiprobably), and if they belong t o 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's the probability, this species would be, the only one to inhabit this Island after a long enough period of time.

Input

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.

Output

Print three space-separated real numbers:the probabilities, at which the rocks, the scissors and the paper'll be is the on ly surviving species, respectively. The answer'll be considered correct if the relative or absolute error of each number doesn ' t exceed -9.

Examples input
2 2 2
Output
0.333333333333 0.333333333333 0.333333333333
Test Instructions:Give you a pair of scissors stone cloth Three kinds of number, each time randomly two, ask you finally respectively left these three probabilityThe following:Assuming that we known quantity the probability of a,b,c is equal to dp[a][b][c]; then we can get dp[a][b][c-1], Dp[a][b-1][c], dp[a-1][b][c]; The violence pushes down, it's solved.
#include <bits/stdc++.h>using namespacestd;Const intN = 1e2+ -, M = 1e6+Ten, mod = 1e9+7, INF = 1e9+ +; typedefLong Longll;DoubleDp[n][n][n];Doublea,b,c;intMain () {intr,s,p; scanf ("%d%d%d",&r,&s,&p); DP[R][S][P]=1;  for(inti=r;i>=0; i--) {         for(intj=s;j>=0; j--) {             for(intk=p;k>=0; k--) {                Doubleall = i*1.0*j+j*1.0*k+k*1.0*i; if(all==0)Continue; if(K-1>=0) dp[i][j][k-1] + = dp[i][j][k]* (Double) (j*1.0*K)/All ; if(J-1>=0) dp[i][j-1][k] + = dp[i][j][k]* (Double) (j*1.0*i)/All ; if(I-1>=0) dp[i-1][j][k] + = dp[i][j][k]* (Double) (i*1.0*K)/All ; }        }    }     for(intI=1; i<=r;i++) a+=dp[i][0][0];  for(intI=1; i<=s;i++) b+=dp[0][i][0];  for(intI=1; i<=p;i++) c+=dp[0][0][i]; printf ("%.9f%.9f%.9f\n", A,b,c); return 0;}

Codeforces Round #301 (Div. 2) D. Bad Luck-island probability DP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.