#include<stdio.h>
#include<vector>
#include<queue>
#include<math.h>
using namespace std;
int n;
double p, r, ans=0;
struct pnode{
int level;
int retail_num;
bool is_retail;
vector<int> child;
}node[100010];
void levelorder(int root){
node[root].level=0;
queue<int> que;
que.push(root);
while(!que.empty()){
int front=que.front();
que.pop();
if(node[front].is_retail){ans+=p*pow((1+r/100),(double)node[front].level)*node[front].retail_num;}
else {
for(vector<int>::iterator it=node[front].child.begin();it!=node[front].child.end();it++){
node[*it].level=node[front].level+1;
que.push(*it);
}//for
}//else
}//while
}
int main(){
int i, j, loop, temp;
scanf("%d%lf%lf",&n,&p,&r);
for(i=0;i<n;i++){
scanf("%d",&loop);
if(loop!=0){
for(j=0;j<loop;j++){
scanf("%d",&temp);
node[i].child.push_back(temp);
node[i].is_retail=false;
}
}
else {
node[i].is_retail=true;
scanf("%d",&node[i].retail_num);
}
}
levelorder(0);
printf("%0.1lf\n",ans);
return 0;
}
PAT-A1079
最新推荐文章于 2022-03-01 17:48:54 发布