【CF540D】Bad Luck Island

题目

展开
题目描述
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]);
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值