http://codeforces.com/problemset/problem/540/D

题目大意:

会出石头、剪刀、布的人分别有r,s,p个,他们相互碰到的概率相同,输的人死掉,问最终活下去的人是三种类型的概率。

思路:

f[i][j][k]代表i个石头,j个剪刀,k个布状态的概率,初始f[n][m][K]=1

 #include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<iostream>
#define dou long double
dou jc[];
dou f[][][];
int n,m,K;
int read(){
int t=,f=;char ch=getchar();
while (ch<''||ch>''){if (ch=='-') f=-;ch=getchar();}
while (''<=ch&&ch<=''){t=t*+ch-'';ch=getchar();}
return t*f;
}
int main(){
n=read();m=read();K=read();
f[n][m][K]=1.0;
for (int i=n;i>=;i--)
for (int j=m;j>=;j--)
for (int k=K;k>=;k--)
if (f[i][j][k]>)
{
int cnt=((int)(i==))+((int)(j==))+((int)(k==));
if (cnt>=) continue;
double tot=i*j+j*k+k*i;
if (i>)
f[i-][j][k]+=f[i][j][k]*(i*k)/tot;
if (j>)
f[i][j-][k]+=f[i][j][k]*(i*j)/tot;
if (k>)
f[i][j][k-]+=f[i][j][k]*(k*j)/tot;
}
double ans1=,ans2=,ans3=;
for (int i=;i<=n;i++)
ans1+=(double)f[i][][];
for (int i=;i<=m;i++)
ans2+=(double)f[][i][];
for (int i=;i<=K;i++)
ans3+=(double)f[][][i];
printf("%.9f %.9f %.9f\n",ans1,ans2,ans3);
return ;
}

Codeforces 540D Bad Luck Island的更多相关文章

  1. CodeForces - 540D Bad Luck Island —— 求概率

    题目链接:https://vjudge.net/contest/226823#problem/D The Bad Luck Island is inhabited by three kinds of ...

  2. Codeforces 540D Bad Luck Island - 概率+记忆化搜索

    [题意] 一个岛上有三种生物A,B,C,各有多少只在输入中会告诉你,每种最多100只 A与B碰面,A会吃掉B, B与C碰面,B会吃掉C, C与A碰面,C会吃掉A...忍不住想吐槽这种环形食物链 碰面是 ...

  3. CodeForces 540D Bad Luck Island (DP)

    题意:一个岛上有石头,剪刀和布,规则就不用说了,问你最后只剩下每一种的概率是多少. 析:很明显的一个概率DP,用d[i][j][k]表示,石头剩下 i 个,剪刀剩下 j 个,布剩下 k 个,d[r][ ...

  4. codeforces 540D Bad Luck Island (概率DP)

    题意:会出石头.剪刀.布的人分别有r,s,p个,他们相互碰到的概率相同,输的人死掉,问最终活下去的人是三种类型的概率 设状态dp(i,j,k)为还有i个石头,j个剪刀,k个布时的概率,dp(r,s,p ...

  5. CF 540D——Bad Luck Island——————【概率dp】

    Bad Luck Island time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  6. Codeforces B. Bad Luck Island(概率dp)

    题目描述: Bad Luck Island time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  7. 540D - Bad Luck Island(概率DP)

    原题链接:http://codeforces.com/problemset/problem/540/D 题意:给你石头.剪刀.布的数量,它们之间的石头能干掉剪刀,剪刀能干掉布,布能干掉石头,问最后石头 ...

  8. CF 540D Bad Luck Island

    一看就是DP题(很水的一道紫题) 设\(dp[i][j][k]\)为留下\(i\)个\(r\)族的人,死去\(j\)个\(s\)族的人,死去\(k\)个\(p\)族的人的概率(跟其他的题解有点差别,但 ...

  9. Codeforces Round #301 (Div. 2) D. Bad Luck Island 概率DP

    D. Bad Luck Island Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/540/pr ...

随机推荐

  1. cursor: pin S

    declare v_sql varchar2(200); begin loop v_sql :='select seq1.nextval from dual'; execute immediate v ...

  2. 查询Linux系统最后重启时间的三个方法

    对于在Linux平台开发或运维的工程师来说,经常需要查询系统最后一次重启的时间,这篇文章将给大家介绍三种方法: 方法一:last命令 # last rebootreboot system boot 2 ...

  3. 【KMP】剪花布条

    KMP算法 又水了一题.算是巩固复习吧. Problem Description 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案.对于给定的花布条和小饰条,计算一下能从花布条中尽 ...

  4. 【转】Windows下使用VS2008编译OpenCV 2.1 添加Intel TBB和Python支持

    Windows下使用VS2008编译OpenCV2.1 添加Intel TBB和Python支持 步骤: 1.仔细阅读OpenCV官网上的InstallGuide:http://opencv.will ...

  5. 接上一篇博客(解决-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment variable and mvn script match. )

    解决-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment variabl ...

  6. node.js + express(ejs) + mongodb(mongoose) 增删改实例

    MongoDB 安装步骤总结: 1.解压目录到d盘 mongodb 2.安装目录的下新建文件mongo.config文件 ##store data here dbpath=D:\mongodb\dat ...

  7. 远程连接mysql,mysql如何开启远程连接

    很多时候,mysql只需要开本地连接,也就是本机(服务器本身)连接就可以,默认也是这样,默认也不支持远程连接 但有的时候,我们需要将mysql独立出一台主机或数据库,放到另一台机器的时候,这时,就需要 ...

  8. [Redux] React Todo List Example (Toggling a Todo)

    /** * A reducer for a single todo * @param state * @param action * @returns {*} */ const todo = ( st ...

  9. HDU4612(Warm up)2013多校2-图的边双连通问题(Tarjan算法+树形DP)

    /** 题目大意: 给你一个无向连通图,问加上一条边后得到的图的最少的割边数; 算法思想: 图的边双连通Tarjan算法+树形DP; 即通过Tarjan算法对边双连通缩图,构成一棵树,然后用树形DP求 ...

  10. Java基础知识强化43:StringBuffer类之StringBuffer和String的相互转化

    1. String和StringBuffer的相互转换 思想是:A-----B的转换,我们把A转换为B,其实是为了使用B的功能:B-----A的转换,我们可能的结果是A类型,所以还要转换回来 2. 案 ...