CodeForces 540D Bad Luck Island (DP)】的更多相关文章

题意:一个岛上有石头,剪刀和布,规则就不用说了,问你最后只剩下每一种的概率是多少. 析:很明显的一个概率DP,用d[i][j][k]表示,石头剩下 i 个,剪刀剩下 j 个,布剩下 k 个,d[r][s][p] = 1,那状态转发方程怎么写呢?是这样的 如果石头减少了1,那么肯定是布干的,那么是哪个布干掉了哪个石头呢?这又是另一个问题,答案就是 i * k,那么总数就是 i * k + i * j + j * k. 最后再把各项加起来即可. 代码如下: #include <iostream>…
题目链接:https://vjudge.net/contest/226823#problem/D 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 i…
题意:会出石头.剪刀.布的人分别有r,s,p个,他们相互碰到的概率相同,输的人死掉,问最终活下去的人是三种类型的概率 设状态dp(i,j,k)为还有i个石头,j个剪刀,k个布时的概率,dp(r,s,p)=1.0 状态转移方程: d(i-1,j,k)+=d(i,j,k)*(i*k)/(i*j+i*k+j*k); d(i,j-1,k)+=d(i,j,k)*(i*j)/(i*j+i*k+j*k); d(i,j,k-1)+=d(i,j,k)*(j*k)/(i*j+i*k+j*k); 因为状态dp(i,j…
[题意] 一个岛上有三种生物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…
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>…
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 ra…
题目描述: 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…
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…
原题链接: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,所以这里的概率为…
一看就是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, &a…