CF 540D Bad Luck Island

一看就是DP题(很水的一道紫题)

设\(dp[i][j][k]\)为留下\(i\)个\(r\)族的人,死去\(j\)个\(s\)族的人,死去\(k\)个\(p\)族的人的概率(跟其他的题解有点差别,但本质相同)。

#include <bits/stdc++.h>
using namespace std;
double dp[101][101][101];
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++) {
            dp[i][j][0] = 1;
            for (int k = 1; k <= 100; k++)
                dp[i][j][k] += (i * j * dp[i][j - 1][k] + j * k * dp[i][j][k - 1] + k * i * dp[i - 1][j][k]) / (i * j + j * k + k * i);
        }
    printf("%.12lf %.12lf %.12lf\n", dp[a][b][c], dp[b][c][a], dp[c][a][b]);
    return 0;
}

原文地址:https://www.cnblogs.com/wjnclln/p/10807598.html

时间: 2024-11-06 11:22:49

CF 540D Bad Luck Island的相关文章

CodeForces 540D Bad Luck Island 概率dp

CodeForces 540D 应该是简单概率dp,由于写得少显得十分蠢萌 求期望逆推,求概率正推,大概是这么个意思,贴一发留恋 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define db double const int maxn=108; db dp[maxn][maxn][maxn]; int main() { int i,j,n,m,k,p; whi

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

[题意] 一个岛上有三种生物A,B,C,各有多少只在输入中会告诉你,每种最多100只 A与B碰面,A会吃掉B, B与C碰面,B会吃掉C, C与A碰面,C会吃掉A...忍不住想吐槽这种环形食物链 碰面是随机的.到最后岛上只剩下一种生物,问这种生物分别是A,B,C的概率是多少. [题解] 其实很简单,这题,状态方程很好想.. 设dp[i][j][k]为生物A有i只,生物B有j只,生物C有k只的概率情况,显然dp的返回值应该有三个,分别是最后剩下该种生物的概率 那么我们考虑状态转移的情况. 如果A与B

540D - Bad Luck Island(概率DP)

原题链接:http://codeforces.com/problemset/problem/540/D 题意:给你石头.剪刀.布的数量,它们之间的石头能干掉剪刀,剪刀能干掉布,布能干掉石头,问最后石头.剪刀.布各自只有一种存活的概率. 思路:dp[i][j][k]为石头剪刀布分别剩下i,j,k个的概率.以布消灭石头为例,从dp[i][j][k]转移到dp[i-1][j][k]需要dp[i][j][k]乘上转移的概率总情况为tot=i*k+i*j+j*k,石头遇上布的情况为i*k,所以这里的概率为

Codeforces 540D Bad Luck Island

http://codeforces.com/problemset/problem/540/D 题目大意: 会出石头.剪刀.布的人分别有r,s,p个,他们相互碰到的概率相同,输的人死掉,问最终活下去的人是三种类型的概率. 思路: f[i][j][k]代表i个石头,j个剪刀,k个布状态的概率,初始f[n][m][K]=1 1 #include<cstdio> 2 #include<cmath> 3 #include<algorithm> 4 #include<cstr

cf 540D D. Bad Luck Island 概率dp

D. Bad Luck Island time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Bad Luck Island is inhabited by three kinds of species: r rocks, s scissors and p papers. At some moments of time two

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

D:Bad Luck Island 一个岛上有r个石头,s个剪子,p个布,他们之间随机挑出两个相遇,如果不是相同物种,就会有一个消失,分别求出最后这座岛上只剩下一个物种的概率. 我们用dp[i][j][k]来存储剩下 i 个石头, j 个剪刀,k 个布时的概率,共dp三次: 如果石头与剪刀碰面,概率是 p1 = i*j / (i*j+j*k+k*i),这种情况下,剪刀会被石头吃掉,所以石头的数目减少1,表现出来是dp[i-1][j][k] = p1*dp[i][j][k]  (dp的3的返回值均

CF 301div2 D. Bad Luck Island

D. Bad Luck Island The Bad Luck Island is inhabited by three kinds of species: r rocks, s scissors and p papers. At some moments of time two random individuals meet (all pairs of individuals can meet equiprobably), and if they belong to different spe

[Codeforces Round #301 (Div. 2) D]Bad Luck Island(概率Dp)

Description The Bad Luck Island is inhabited by three kinds of species: r rocks, s scissors and p papers. At some moments of time two random individuals meet (all pairs of individuals can meet equiprobably), and if they belong to different species, t

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

D. Bad Luck Island The Bad Luck Island is inhabited by three kinds of species: r rocks, s scissors and p papers. At some moments of time two random individuals meet (all pairs of individuals can meet equiprobably), and if they belong to different spe