#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
struct node
{
int weight=0;
vector<int> child;
}nodes[maxn];
int n;
double p,r;
double totalPrice = 0;
void BFS(int root,int depth)
{
//叶子结点
if(nodes[root].child.size() == 0)
{
totalPrice += nodes[root].weight*p*pow(1+r,depth);
return;
}
else
{
for(int i=0;i<nodes[root].child.size();i++)
{
BFS(nodes[root].child[i],depth+1);
}
}
}
int main()
{
scanf("%d",&n);
scanf("%lf%lf",&p,&r);
r /= 100;
for(int i=0;i<n;i++)
{
int Childnumber;
scanf("%d",&Childnumber);
if(Childnumber != 0)
{
for(int j=0;j<Childnumber;j++)
{
int childNo;
scanf("%d",&childNo);
nodes[i].child.push_back(childNo);
}
}
else
{
int weight;
scanf("%d",&weight);
nodes[i].weight = weight;
}
}
//遍历
BFS(0,0);
printf("%.1lf",totalPrice);
}
A1079 Total Sales of Supply Chain (25 分)
最新推荐文章于 2022-03-01 17:48:54 发布