POJ 3156 - Interconnect (概率DP+hash)】的更多相关文章

题意:给一个图,有些点之间已经连边,现在给每对点之间加边的概率是相同的,问使得整个图连通,加边条数的期望是多少. 此题可以用概率DP+并查集+hash来做. 用dp(i,j,k...)表示当前的每个联通分量的点数分别是i,j,k...(连通分量的个数不固定)时,加边的期望. 这样以dp(i,j,k)为例分析状态转移的过程,dp(i,j,k)=p1*dp(i,j,k)+p2*dp(i+j,k)+p3*dp(i,j+k)+p4*dp(j,i+k)+1. 终止条件是dp(n)=0,因为此时图一定联通,…
///有c种不同颜色的巧克力.一个个的取.当发现有同样的颜色的就吃掉.去了n个后.到最后还剩m个的概率 ///dp[i][j]表示取了i个还剩j个的概率 ///当m+n为奇时,概率为0 # include <stdio.h> # include <algorithm> # include <string.h> # include <iostream> using namespace std; double dp[1010][1010]; int main()…
题目链接 不1Y都对不住看过那么多年的球.dp[i][j]表示i队进入第j轮的概率,此题用0-1<<n表示非常方便. #include <cstdio> #include <cstring> #include <iostream> #include <cmath> #include <algorithm> using namespace std; ][]; ][]; int main() { int n,i,j,mod,c,k,ans…
Description YYF is a couragous scout. Now he is on a dangerous mission which is to penetrate into the enemy's base. After overcoming a series difficulties, YYF is now at the start of enemy's famous "mine road". This is a very long road, on which…
题意:有T个队伍,有M道题,要求每个队至少有一道题,并且有队伍至少过N道题的概率. 这个题解主要讲一下,后面的,至少有一道题解决和至少一道题至N-1道题解决,到底怎么算的,其实,很简单,就是母函数. ac代码: #include<cstdio> #define N 1001 #define T 31 double dp[N][T][T]; double p[N][T]; int main() { int m, t, n; while (scanf("%d%d%d", &am…
G - Football Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Description Consider a single-elimination football tournament involving 2n teams, denoted 1, 2, …, 2n. In each round of the tournament, all teams…
http://poj.org/problem?id=1202 难度集中在输出格式上,因为输出格式所以是高精度 递推式: 血缘肯定只有从双亲传到儿子的,所以,设f,m为双亲,son为儿子,p[i][j]为i和j之间的血缘关系,p[j][i]=p[i][j] 则: p[son][f]=p[son][m]=0.5+0.5*p[f][m] 对于兄弟和其他不是双亲的节点j,则有 p[son][j]=0.5*(p[f][j]+p[m][j]) 另外:http://swerc.up.pt/2002/Data/…
id=3071">http://poj.org/problem? id=3071 大致题意:有2^n个足球队分成n组打比赛.给出一个矩阵a[][],a[i][j]表示i队赢得j队的概率.n次比赛的流程像这样action=showproblem&problemid=2304">France \'98. 问最后哪个队最可能得冠军. 思路:概率dp问题.ans[i][j]表示第i轮中j队获胜的概率. #include <stdio.h> #include &l…
Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8903   Accepted: 3772 Description Organizing a programming contest is not an easy job. To avoid making the problems too difficult, the organizer usually exp…
Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other material stuff, he collects software bugs. When Ivan gets a new program, he classifies all possible bugs into n categories. Each day he discovers exactly one bug…