题目
展开
题目描述
The Bad Luck Island is inhabited by three kinds of species: rr rocks, ss scissors and pp 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 rr , ss and pp ( 1<=r,s,p<=1001<=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}10
−9
.
题意翻译
给三种人,分别是r,s,p个;
在孤岛上,每两个不同种人相遇则互吃,r吃s,s吃p,p吃r
求最后留下单一种族的概率
输入输出样例
输入 #1复制
2 2 2
输出 #1复制
0.333333333333 0.333333333333 0.333333333333
输入 #2复制
2 1 2
输出 #2复制
0.150000000000 0.300000000000 0.550000000000
输入 #3复制
1 1 3
输出 #3复制
0.057142857143 0.657142857143 0.285714285714
思路
一不小心刷到了一题水题
设f[i][j][k]为有i个石头存货,死了j个剪刀,k个布的概率
dp一下就行了
代码
#include<bits/stdc++.h>
using namespace std;
const int N=107;
double f[N][N][N];
int a,b,c;
int main()
{
scanf("%d%d%d",&a,&b,&c);
for(int i=1; i<=100; i++)
for(int j=1; j<=100; j++)
{
f[i][j][0]=1;
for(int k=1; k<=100; k++)
f[i][j][k]+=(i*j*f[i][j-1][k]+j*k*f[i][j][k-1]+k*i*f[i-1][j][k])/(i*j+j*k+k*i);
}
printf("%.12lf %.12lf %.12lf\n",f[a][b][c],f[b][c][a],f[c][a][b]);
}