嘟嘟嘟




看到数据范围很小,就可以暴力\(O(n ^ 3)\)dp啦。

我们令\(dp[i][j][k]\)表示这三种人分别剩\(i, j, k\)个的概率。然后枚举谁挂了就行。

这里的重点在于两个人相遇的概率是多少,拿\(i, j\)举例,乍一看是\(\frac{i * j}{(i + j + k) * (i + j + k - 1)}\),但这里包含了同一种族相遇的概率,这种情况还应该转移到\(dp[i][j][k]\),这样无限循环下去还是到了这个状态。所以我们的概率不应该包含同一种人相遇的情况,或者说这是一个条件概率,那么就是\(\frac{i * j}{i * j + i * k + j * k}\)。

剩下两种人同理。

#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
#include<assert.h>
using namespace std;
#define enter puts("")
#define space putchar(' ')
#define Mem(a, x) memset(a, x, sizeof(a))
#define In inline
typedef long long ll;
typedef double db;
const int INF = 0x3f3f3f3f;
const db eps = 1e-14;
const int maxn = 105;
In ll read()
{
ll ans = 0;
char ch = getchar(), last = ' ';
while(!isdigit(ch)) last = ch, ch = getchar();
while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
if(last == '-') ans = -ans;
return ans;
}
In void write(ll x)
{
if(x < 0) x = -x, putchar('-');
if(x >= 10) write(x / 10);
putchar(x % 10 + '0');
}
In void MYFILE()
{
#ifndef mrclr
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
} int n, m, l;
db f[maxn][maxn][maxn]; int main()
{
//MYFILE();
n = read(), m = read(), l = read();
f[n][m][l] = 1;
for(int i = n; i >= 0; --i)
for(int j = m; j >= 0; --j)
for(int k = l; k >= 0; --k)
if(f[i][j][k] > eps)
{
db tot = i * j + i * k + j * k;
if(i && k) f[i - 1][j][k] += f[i][j][k] * i * k / tot;
if(i && j) f[i][j - 1][k] += f[i][j][k] * i * j / tot;
if(j && k) f[i][j][k - 1] += f[i][j][k] * j * k / tot;
}
db ans = 0;
for(int i = 1; i <= n; ++i) ans += f[i][0][0];
printf("%.12lf ", ans);
ans = 0;
for(int i = 1; i <= m; ++i) ans += f[0][i][0];
printf("%.12lf ", ans);
ans = 0;
for(int i = 1; i <= l; ++i) ans += f[0][0][i];
printf("%.12lf\n", ans);
return 0;
}

CF540D Bad Luck Island的更多相关文章

  1. cf540D. Bad Luck Island(概率dp)

    题意 岛上有三个物种:剪刀$s$.石头$r$.布$p$ 其中剪刀能干掉布,布能干掉石头,石头能干掉剪刀 每天会从这三个物种中发生一场战争(也就是说其中的一个会被干掉) 问最后仅有$s/r/p$物种生存 ...

  2. CF540D Bad Luck Island(期望dp)

    传送门 解题思路 比较容易的一道期望\(dp\),设\(f[i][j][k]\)表示石头\(i\)个,剪刀\(j\)个,步子\(l\)个.然后转移的时候用组合数算一下就好了. 代码 #include& ...

  3. 【CF540D】 D. Bad Luck Island (概率DP)

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

  4. cf.301.D. Bad Luck Island(dp + probabilities)

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

  5. 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 ...

  6. CF#301 D:Bad Luck Island (概率dp)

    D:Bad Luck Island 一个岛上有r个石头,s个剪子,p个布,他们之间随机挑出两个相遇,如果不是相同物种,就会有一个消失,分别求出最后这座岛上只剩下一个物种的概率. 我们用dp[i][j] ...

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

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

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

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

  9. Codeforces 540 D Bad Luck Island

    Discription The Bad Luck Island is inhabited by three kinds of species: r rocks, s scissors andp pap ...

随机推荐

  1. echarts的基本使用以及如何使用官方实例的方法

    <!-- 为 ECharts 准备一个具备大小(宽高)的 DOM --> <div id="box" style="width: 600px;heigh ...

  2. SpringCloud Stream 消息驱动

    1.什么是消息驱动 SpringCloud Stream消息驱动可以简化开发人员对消息中间件的使用复杂度,让系统开发人员更多尽力专注与核心业务逻辑的开发.SpringCloud Stream基于Spr ...

  3. 扩展kmp入门+比赛模板

    https://wenku.baidu.com/view/8e9ebefb0242a8956bece4b3.html 参考了这个ppt 理解起来还是有点费劲的(还是推荐一下这个课件 里面概念和思路给的 ...

  4. taglist and nerdtree

    函数:function! s:Tlist_Window_Exit_Only_Window()中的winbunr(2)改为winbunr(3),即只剩2个窗口时关闭,考虑到2个窗口肯定是同时存在,所以这 ...

  5. 实现Bootstrap表格拖拽

    实现Bootstrap表格拖拽: 需要引入jquery.min.js.bootstrap相关文件,以及jquery.dragsort-0.5.2.js 代码如下: <html> <h ...

  6. ajax请求的五个步骤

    创建XMLHttpRequest异步对象 var xhr = new XMLHttpRequest() 设置回调函数 xhr.onreadystatechange = callback 使用open方 ...

  7. 如何使 JavaScript 更高效?

    传统的 Web 页面不会包含很多脚本,至少不会太影响 Web 页面的性能.然而,Web 页面变得越来越像应用程序,脚本对其的影响也越来越大.随着越来越多的应用采用 Web 技术开发,脚本性能的提升就变 ...

  8. main函数前后

    void f1(void)__attribute__((constructor)); void f2(void)__attribute__((destructor)); void f1(void) { ...

  9. mongodb备份每一天的数据

    需求:把mongodb里面存储6个月的数据备份到本地,一天天的来备份,方便对备份管理.然后mongo保留一周的数据(优化查询速度,可以用mongo的ttl来实现,但是我的业务场景不太适合用ttl索引) ...

  10. 爬虫如何发现更多的url呢,怎么动态收集新的url连接

    大家在做爬虫采集数据的时候很多都会遇到增量采集的问题,有些时候是通过过滤url来进行的,有些是通过爬取网页后再进行分析判断, 以上这些过程也许大部分做爬虫的都会这么做,各位有没有想过, 除了以上的常用 ...