#include <iostream>
#include <cstdio>
#include <cmath>
#define max 110
using namespace std;
int Tree[max];
int main(int argc, char** argv) {
int m, n, tar;
while (scanf("%d%d%d", &m, &n, &tar) != EOF) {
for (int i = 0; i < m; ++i) {
Tree[i] = -1;
}
while (n--) {
int a, b;
scanf("%d%d", &a, &b);
Tree[b] = a;
}
float res = 1.0;
int now = tar;
int fa = Tree[now];
while (fa != -1) {
int cnt = 0;
for (int i = 0; i < m; ++i) {
if (Tree[i] == fa) ++cnt;
}
res *= 1.0 / cnt;
now = fa;
fa = Tree[now];
}
int tmp = (int)res*pow(10, 7); // 四舍五入
if (tmp % 10 >= 5) res += 0.000001;
printf("%.6f\n", res);
}
return 0;
}
//11 10 6
//0 1
//0 2
//1 3
//2 4
//2 5
//3 8
//3 10
//4 6
//5 7
//6 9
//0.250000
2011计算机C 寻找宝藏
最新推荐文章于 2023-08-18 13:38:26 发布