#include<iostream> #include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> #include<algorithm> #include<map> #include<vector> #include<queue> using namespace std; //key:DFS递归 树结点存储 const int maxn=100010; struct node{ double data; //数据域(货物量) vector<int> child; //指针域 }Node[maxn]; //存放树 int n; double p,r,ans=0; //ans为叶结点货物的价格之和 void DFS(int index,int depth){ //注意!根结点的深度设为0! if(Node[index].child.size()==0){ //到达叶结点 ans+= Node[index].data*pow(1+r,depth); //累加叶结点货物的价格 return ; } for(int i=0;i<Node[index].child.size();i++){ DFS(Node[index].child[i],depth+1); //递归访问子结点 } } int main(){ int k,child; scanf("%d%lf%lf",&n,&p,&r); r/=100; for(int i=0;i<n;i++){ scanf("%d",&k); if(k==0){ //叶结点标志 scanf("%lf",&Node[i].data); //叶结点货物量 }else{ for(int j=0;j<k;j++){ scanf("%d",&child); Node[i].child.push_back(child); //child为结点i的子结点 } } } DFS(0,0); //DFS入口 printf("%.1f\n",p*ans); //输出结果 system("pause"); return 0; }