2014鞍山网络预选赛1005(概率DP)hdu5001

Walk

Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 209    Accepted Submission(s): 146

Special Judge

Problem Description

I used to think I could be anything, but now I know that I couldn‘t do anything. So I started traveling.

The nation looks like a connected bidirectional graph, and I am randomly walking on it. It means when I am at node i, I will travel to an adjacent node with the same probability in the next step. I will pick up the start node randomly (each node in the graph
has the same probability.), and travel for d steps, noting that I may go through some nodes multiple times.

If I miss some sights at a node, it will make me unhappy. So I wonder for each node, what is the probability that my path doesn‘t contain it.

Input

The first line contains an integer T, denoting the number of the test cases.

For each test case, the first line contains 3 integers n, m and d, denoting the number of vertices, the number of edges and the number of steps respectively. Then m lines follows, each containing two integers a and b, denoting there is an edge between node
a and node b.

T<=20, n<=50, n-1<=m<=n*(n-1)/2, 1<=d<=10000. There is no self-loops or multiple edges in the graph, and the graph is connected. The nodes are indexed from 1.

Output

For each test cases, output n lines, the i-th line containing the desired probability for the i-th node.

Your answer will be accepted if its absolute error doesn‘t exceed 1e-5.

Sample Input

2
5 10 100
1 2
2 3
3 4
4 5
1 5
2 4
3 5
2 5
1 4
1 3
10 10 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
4 9

Sample Output

0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.0000000000
0.6993317967
0.5864284952
0.4440860821
0.2275896991
0.4294074591
0.4851048742
0.4896018842
0.4525044250
0.3406567483
0.6421630037

题意:RT

思路:这题比赛的时候是队友过的,不过还是想做一做,一个人会不如两个人都会,哈~~

DP[ i ][ j ]表示当前走到 i 结点,没有经过 j 的概率

暴力转移d步就好了,每一步都遍历每条边

假设i和j有边,现在这一步要从 i 走到 j 不经过 k ,转移为DP[j][k]+=DP[i][k],其中k不能等于 j

时间: 2024-07-29 03:52:56

2014鞍山网络预选赛1005(概率DP)hdu5001的相关文章

2014鞍山网络预选赛1004(贪心)hdu5000

Clone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 291    Accepted Submission(s): 131 Problem Description After eating food from Chernobyl, DRD got a super power: he could clone himself righ

2014北京网络预选赛1005(强连通缩点+期望)HDU5036

Explosion Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 243    Accepted Submission(s): 63 Problem Description Everyone knows Matt enjoys playing games very much. Now, he is playing such a g

2014鞍山网络预选赛1006(LCT模板题)hdu5002

Tree Time Limit: 16000/8000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 41    Accepted Submission(s): 10 Problem Description You are given a tree with N nodes which are numbered by integers 1..N. Each node is as

2014鞍山网络预选赛1010(缩点+高斯消元)hdu5006

Resistance Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 280    Accepted Submission(s): 82 Problem Description Recently DRD got a number of wires. Some of the wires have the resistance 1 ohm

hdu 4050 2011北京赛区网络赛K 概率dp ***

题目:给出1-n连续的方格,从0开始,每一个格子有4个状态,左右脚交替,向右跳,而且每一步的步长必须在给定的区间之内.当跳出n个格子或者没有格子可以跳的时候就结束了,求出游戏的期望步数 0:表示不能到达这个格子 1:表示左脚跳进这个格子 2:表示右脚跳进这个格子 3:随意哪个脚跳进这个格子,而且下一步随意用哪个脚 dp[i][j] :表示走到第 i 个格子在 j 状态的期望. 当j=1时,你可以走到dp[i+k][2],dp[i+k][3], 当j=2时,你可以走到dp[i+k][1],dp[i

2014牡丹江网络预选赛D题(状压DP)zoj3812

We Need Medicine Time Limit: 10 Seconds      Memory Limit: 65536 KB      Special Judge A terrible disease broke out! The disease was caused by a new type of virus, which will lead to lethal lymphoedema symptom. For convenience, it was named LL virus.

2014牡丹江网络预选赛I题(字符串hash+简单DP)zoj3817

Chinese Knot Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Chinese knot is a decorative handicraft that began as a form of Chinese folk artifact in the Tang and Song Dynasty in China. It was later popularized in the Ming. Alice

hdu 4035 2011成都赛区网络赛E 概率dp ****

太吊了,反正我不会 1 /* 2 HDU 4035 3 4 dp求期望的题. 5 题意: 6 有n个房间,由n-1条隧道连通起来,实际上就形成了一棵树, 7 从结点1出发,开始走,在每个结点i都有3种可能: 8 1.被杀死,回到结点1处(概率为ki) 9 2.找到出口,走出迷宫 (概率为ei) 10 3.和该点相连有m条边,随机走一条 11 求:走出迷宫所要走的边数的期望值. 12 13 设 E[i]表示在结点i处,要走出迷宫所要走的边数的期望.E[1]即为所求. 14 15 叶子结点: 16

HDU-5000 Clone 鞍山网络赛D题 DP+猜想

一个人可以克隆出自己克隆体,一个克隆体有n个方面,如果一个克隆体全方面逊色于另外一个克隆体,那么它就无法存活下去,问怎样可以同时最多存活的克隆体数目.思路:得到最大值的时候,每个克隆体的属性之和必然是相同的,并且这个和是所有方面最高属性和的二分之一.问题就变成n个数组成sum/2的方案数. #include <iostream> #include <cstdio> #include <cmath> #include <queue> #include <