题意

岛上有三个物种:剪刀$s$、石头$r$、布$p$

其中剪刀能干掉布,布能干掉石头,石头能干掉剪刀

每天会从这三个物种中发生一场战争(也就是说其中的一个会被干掉)

问最后仅有$s/r/p$物种生存的概率

Sol

还是想复杂了啊,我列的状态时$f[i][j], g[i][j],t[i][j]$分别表示第$i$天,$j$个$s, r, p$活着的概率

然而转移了一下午也没转移出来。。

标算比我简单的多,直接设$f[i][j][k]$表示剩下$i$个$s$,$j$个$r$,$k$个$p$的概率

然后记忆化搜索一下

/*

*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/hash_policy.hpp>
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
#define int long long
#define LL long long
#define ull unsigned long long
#define rg register
#define pt(x) printf("%d ", x);
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 22)], *p1 = buf, *p2 = buf;
//char obuf[1<<24], *O = obuf;
//void print(int x) {if(x > 9) print(x / 10); *O++ = x % 10 + '0';}
//#define OS *O++ = ' ';
using namespace std;
//using namespace __gnu_pbds;
const int MAXN = 1e6 + , INF = 1e9 + , mod = 1e9 + ;
const double eps = 1e-;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
double a, b, c;
double f[][][];
double calca(int a, int b, int c) {
if(f[a][b][c]) return f[a][b][c];
if(a == ) return f[a][b][c] = ;
if(a && (!b) && (!c)) return f[a][b][c] = ;
double down = a * b + b * c + a * c, ans = ;
if(a && b) ans += (double) a * b / down * calca(a, b - , c);
if(b && c) ans += (double) b * c / down * calca(a, b, c - );
if(a && c) ans += (double) a * c / down * calca(a - , b, c);
return f[a][b][c] = ans;
}
double calcb(int a, int b, int c) {
if(b == ) return f[a][b][c] = ;
if((!a) && b && (!c)) return f[a][b][c] = ;
if(f[a][b][c]) return f[a][b][c];
double down = a * b + b * c + a * c, ans = ;
if(a && b) ans += (double) a * b / down * calcb(a, b - , c);
if(b && c) ans += (double) b * c / down * calcb(a, b, c - );
if(a && c) ans += (double) a * c / down * calcb(a - , b, c);
return f[a][b][c] = ans;
}
main() {
a = read(); b = read(); c = read();
double a1 = , a2 = ;
printf("%.10lf ", a1 = calca(a, b, c)); memset(f, , sizeof(f));
printf("%.10lf ", a2 = calcb(a, b, c));
printf("%.10lf", - a1 - a2);
return ;
}
/*
2 2 1
1 1
2 1 1
*/

cf540D. Bad Luck Island(概率dp)的更多相关文章

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

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

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

  3. CF540D Bad Luck Island(期望dp)

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

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

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

  5. CF540D Bad Luck Island

    嘟嘟嘟 看到数据范围很小,就可以暴力\(O(n ^ 3)\)dp啦. 我们令\(dp[i][j][k]\)表示这三种人分别剩\(i, j, k\)个的概率.然后枚举谁挂了就行. 这里的重点在于两个人相 ...

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

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

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

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

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

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

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

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

随机推荐

  1. 1101 Quick Sort(25 分

    There is a classical process named partition in the famous quick sort algorithm. In this process we ...

  2. myeclipse集成svn客户端

    转载大神 https://blog.csdn.net/tandeng19901222/article/details/5979075

  3. Chapter12

    package scalaimport java.awt.event.{ActionEvent, ActionListener}import javax.swing.JButton import sc ...

  4. 注意sqlite3和java的整数数据类型的区别

    作为新手的我,没有考虑数据库和java的数据类型的对应上的区别: sqlite3的数据类型和java数据类型对应上要小心,特别是整数类型. java 中int类型4位存储,范围 -2^31到2^31- ...

  5. TypeScript 装饰器

    装饰器(Decorators)可用来装饰类,属性,及方法,甚至是函数的参数,以改变和控制这些对象的表现,获得一些功能. 装饰器以 @expression 形式呈现在被装饰对象的前面或者上方,其中 ex ...

  6. pat1098. Insertion or Heap Sort (25)

    1098. Insertion or Heap Sort (25) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...

  7. strstr strcpy 函数的实现

    一. strcpy 代码实现 #include <iostream> #include <assert.h> #include <iostream> //#incl ...

  8. Josn转换

    也是搬的,大家勿喷,贴出来只为了自己记忆查找 需要引用 System.Web.Extensions.dll 这个类库 命名空间: System.Web.Script.Serialization 数据结 ...

  9. 基于FCM的消息推送功能

    需求背景 我方项目需要支持客户端消息推送,iOS终端可以借由苹果本身的apns很方便的实现,但是对于Android来说,必须集成第三方的SDK来处理.考虑到项目需要以及成本,我们选择使用谷歌的FCM框 ...

  10. springBoot学习 错误记录

    1.下面结果 会出现500错误 原因:thymeleaf相关包版本不兼容导致 解决:之前配置的3.0.9对应2.1.1&2.2.2,3.0.6对应2.2.2&2.1.1都不可以,下面的 ...