#include <cstdio>
#include <vector>
#include <cmath>
#include<iostream>
using namespace std;
struct node {
double data;
vector<int> child;
};
vector<node> v;
double ans = 0.0, p, r;
void dfs(int index, int depth) {
if(v[index].child.size() == 0) {
ans += v[index].data * pow(1 + r, depth);
return ;
}
for(int i = 0; i < v[index].child.size(); i++)
dfs(v[index].child[i], depth + 1);
}
int main() {
int n, k, c;
scanf("%d %lf %lf", &n, &p, &r);
r = r / 100;
v.resize(n);
for(int i=0;i<n;i++){
cin>>k;
if(k){
for(int j=0;j<k;j++){
cin>>c;
v[i].child.push_back(c);
}
}else cin>>v[i].data;
}
dfs(0, 0);
printf("%.1f", ans * p);
return 0;
}
PAT甲级 1079 Total Sales of Supply Chain
最新推荐文章于 2021-09-13 18:56:22 发布