北邮oj---寻找宝藏

题目:http://10.105.242.80/problem/p/105/ 树形结构问题,算是比较简单的了 #include#includeusing

题目:http://10.105.242.80/problem/p/105/

树形结构问题,算是比较简单的了

#include
#include
using namespace std;
struct TreeNode{vector son;int f;
};
int main(){int N,M,L;scanf("%d%d%d",&N,&M,&L);TreeNode node[1010];while(M--){int A,B;scanf("%d%d",&A,&B);node[A].son.push_back(B);node[B].f=A;}int tn=L;double result=1.0;while(tn!=0){TreeNode fa=node[node[tn].f];result*=1.0/(double)fa.son.size();tn=node[tn].f;}printf("%.6lf\n",result);return 0;
}