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

Source
2014 ACM/ICPC Asia Regional Anshan Online


题意:给定一个无向图,求每个顶点不被经过的概率;
考虑dp;
dp[ i ][ j ]表示经过i点已经走过j步时,枚举点K的概率;
我们每次枚举不经过的点,然后转移即可;
当然我们用 vector 存边比较方便;

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
#include<cctype>
//#pragma GCC optimize("O3")
using namespace std;
#define maxn 200005
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
typedef long long  ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const int mod = 1e9 + 7;
#define Mod 20100403
#define sq(x) (x)*(x)
#define eps 1e-10
const int N = 1505;

inline int rd() {
	int x = 0;
	char c = getchar();
	bool f = false;
	while (!isdigit(c)) {
		if (c == '-') f = true;
		c = getchar();
	}
	while (isdigit(c)) {
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	return f ? -x : x;
}

ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
ll sqr(ll x) { return x * x; }


int n, m, d;
double dp[100][20000];
vector<int>vc[100];
double res[100];

int main()
{
	//ios::sync_with_stdio(false);
	int T; rdint(T);
	while (T--) {
		rdint(n); rdint(m); rdint(d);
		for (int i = 0; i <= 100; i++)vc[i].clear();
		ms(res); ms(dp);
		for (int i = 1; i <= m; i++) {
			int u, v; rdint(u); rdint(v);
			vc[u].push_back(v); vc[v].push_back(u);
		}
		for (int i = 1; i <= n; i++) {
			ms(dp);
			for (int j = 1; j <= n; j++)
				dp[j][0] = 1.0 / n;
			for (int j = 0; j < d; j++) {
				for (int k = 1; k <= n; k++) {
					if (i == k)continue;
					int Size = vc[k].size();
					for (int o = 0; o < Size; o++) {
						int v = vc[k][o];
						dp[v][j + 1] += ((dp[k][j])*1.0 / Size);
					}
				}
			}
			res[i] = 0.0;
			for (int j = 1; j <= n; j++) {
				if (i != j) {
					res[i] += dp[j][d];
				}
			}
		}
		for (int i = 1; i <= n; i++)
			printf("%.7lf\n", res[i]);
	}
	return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
#include<cctype>
//#pragma GCC optimize("O3")
using namespace std;
#define maxn 200005
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
typedef long long  ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const int mod = 1e9 + 7;
#define Mod 20100403
#define sq(x) (x)*(x)
#define eps 1e-10
const int N = 1505;

inline int rd() {
	int x = 0;
	char c = getchar();
	bool f = false;
	while (!isdigit(c)) {
		if (c == '-') f = true;
		c = getchar();
	}
	while (isdigit(c)) {
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	return f ? -x : x;
}

ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
ll sqr(ll x) { return x * x; }


int n, m, d;
double dp[100][20000];
vector<int>vc[100];
double res[100];

int main()
{
	//ios::sync_with_stdio(false);
	int T; rdint(T);
	while (T--) {
		rdint(n); rdint(m); rdint(d);
		for (int i = 0; i <= 100; i++)vc[i].clear();
		ms(res); ms(dp);
		for (int i = 1; i <= m; i++) {
			int u, v; rdint(u); rdint(v);
			vc[u].push_back(v); vc[v].push_back(u);
		}
		for (int i = 1; i <= n; i++) {
			ms(dp);
			for (int j = 1; j <= n; j++)
				dp[j][0] = 1.0 / n;
			for (int j = 0; j < d; j++) {
				for (int k = 1; k <= n; k++) {
					if (i == k)continue;
					int Size = vc[k].size();
					for (int o = 0; o < Size; o++) {
						int v = vc[k][o];
						dp[v][j + 1] += ((dp[k][j])*1.0 / Size);
					}
				}
			}
			res[i] = 0.0;
			for (int j = 1; j <= n; j++) {
				if (i != j) {
					res[i] += dp[j][d];
				}
			}
		}
		for (int i = 1; i <= n; i++)
			printf("%.7lf\n", res[i]);
	}
	return 0;
}