//ac
//特别注意1.00转化成百分数!!这个错误看了半天!
//注意定义产品数最好定义为实数
#include<cstdio>
#include<vector>
#include<cmath>
//#define LOCAL
using namespace std;
const int maxn=100010;
int n;
double p,r,total=0.0;
struct Node{
double data;//如果是孩子节点,这个就不为空
vector<int> child;//数组的每个元素只需要一个可变数组存放孩子就可以了
}Node[maxn];
void DFS(int index,int depth){
if(Node[index].data!=0){//说明是孩子结点,可以计算了
total+=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(){
#ifdef LOCAL
freopen("A1079data.in","r",stdin);
freopen("A1079data.out","w",stdout);
#endif
scanf("%d%lf%lf",&n,&p,&r);
r/=100;//一开始这个没写,错大了!
int m,temp;
for(int i=0;i<n;i++){
scanf("%d",&m);
if(m==0){
scanf("%d",&temp);
Node[i].data=temp;
continue;
}
while(m--){
scanf("%d",&temp);
Node[i].child.push_back(temp);
}
}
DFS(0,0);//DFS入口
printf("%.1lf",p*total);
return 0;
}
PAT A1079
最新推荐文章于 2022-03-01 17:48:54 发布