#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
struct node{
int data;
vector<int> child;
}Node[100010];
int N;
double P,r;
double sum;
void DFS(int index,int depth){
if(Node[index].child.size()==0){
sum = sum + 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() {
cin>>N>>P>>r;
r=r/100;
for(int i =0 ;i<N;i++){
int number;
cin>>number;
if(number==0){
cin>>Node[i].data;
} else{
for(int j=0;j<number;j++){
int child;
cin>>child;
Node[i].child.push_back(child);
}
}
}
DFS(0,0);
printf("%.1f",P*sum);
return 0;
}
浙江大学PAT甲级A1079(C++)题解
最新推荐文章于 2021-09-03 15:58:27 发布