#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
int N;
double p,r;
struct node
{
vector<int> child;
};
node cube[100005];
int amount[100005]={0};
double ans=0;
void dfs(int id,int depth)
{
if(cube[id].child.size()==0)
{
ans+=p*pow(1+r/100,depth)*amount[id];
return;
}
for(int i=0;i<cube[id].child.size();i++)
{
dfs(cube[id].child[i],depth+1);
}
return;
}
int main()
{
//freopen("in.txt","r",stdin);
scanf("%d %lf %lf",&N,&p,&r);
for(int i=0;i<N;i++)
{
int n;
scanf("%d",&n);
if(n==0)
{
int t;
scanf("%d",&t);
amount[i]=t;
}
else
{
for(int j=0;j<n;j++)
{
int t;
scanf("%d",&t);
cube[i].child.push_back(t);
}
}
}
dfs(0,0);
printf("%.1f",ans);
return 0;
}
1079. Total Sales of Supply Chain (25)--dfs
最新推荐文章于 2020-09-23 10:13:56 发布