水题
#include<iostream>
#include<iomanip>
using namespace std;
class node
{public:
int parent;
int branches;
node()
{
branches=0;
parent=-1;
}
};
const int MAXSIZE = 10000;
class tree
{public:
node point[MAXSIZE];
int num;
};
int main()
{
int N,M,L;
cin>>N>>M>>L;
int fa,son;
tree res;
res.num=N;
while(M--)
{
cin>>fa>>son;
res.point[fa].branches++;
res.point[son].parent=fa;
}
node temp=res.point[L];
int total_branches=1;
while(temp.parent!=-1)
{
total_branches*=res.point[temp.parent].branches;
temp=res.point[temp.parent];
}
cout.setf(ios::fixed);
cout<<setprecision(6)<<1.0/total_branches<<endl;
}