题意

岛上有三个物种:剪刀$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. Microsoft JDBC Driver 使用 getParameterMetaData 会报错?

    不知道为何使用 Microsoft JDBC Driver for SQL Server 驱动时,sql语句不带参数没有问题,但是如果带参数且使用 getParameterMetaData 就会提示某 ...

  2. java对象在内存中的分配

    java对象在内存中的分配 http://blog.csdn.net/qq_30753945/article/details/54974899

  3. 016 3Sum Closest 最接近的三数之和

    Given an array S of n integers, find three integers in S such that the sum is closest to a given num ...

  4. Spring RestTemplate GET 请求参数

    @Test public void testUpdateProfitJson_GET_Params() throws BusinessException { String apiURL="U ...

  5. linkedlist--lecture-4

    1.链表数据结构 内存利用率高:动态分配 2.链表类定义 单向链表节点 public calss ListNode { int val =0; ListNode next = null; public ...

  6. Spark-2.4.0源码:sparkContext

    在看sparkContext之前,先回顾一下Scala的语法.Scala构造函数分主构造和辅构造函数,辅构造函数是关键字def+this定义的,而类中不在方法体也不在辅构造函数中的代码就是主构造函数, ...

  7. JS语法字典---网友总结

    1.document.write(""); 输出语句2.JS中的注释为//3.传统的HTML文档顺序是:document->html->(head,body)4.一个浏 ...

  8. HQL语句中的join fetch

    from Paper as paper join fetch paper.authors as authors where authors.id='xxxx'; from Paper as paper ...

  9. 字符串json转成json对象

    方法1 JsonSerializer serializer = new JsonSerializer(); TextReader tr = new StringReader(text); JsonTe ...

  10. Linux - 数值运算

    Shell - 数值运算 因为shell脚本是属于弱语言,没有变量类型的概念,所以定义变量会默认为字符串.就算看上去是一个数字,当直接进行计算时,就会出错: x=1 echo $x+=1 # 输出1+ ...