#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
const int maxn=100010;
struct Node
{
int weight;
vector<int> child;
}node[maxn];
int n;
double p,r;
double ans=0;
int maxdepth=-1;
int _time[maxn]={0};
void dfs(int index,int depth)
{
if(node[index].child.size()==0)
{
if(depth>=maxdepth)
{
maxdepth=depth;
_time[maxdepth]++;
}
return;
}
for(int i=0;i<node[index].child.size();i++)
{
int child=node[index].child[i];
dfs(child,depth+1);
}
}
int main()
{
scanf("%d%lf%lf",&n,&p,&r);
int k,root;
for(int i=0;i<n;i++)
{
scanf("%d",&k);
if(k!=-1)
node[k].child.push_back(i);
else
root=i;
}
dfs(root,0);
ans=p*pow(r/100+1,maxdepth);
printf("%.2lf %d",ans,_time[maxdepth]);
system("pause");
return 0;
}
PAT 1090
最新推荐文章于 2020-11-01 13:28:34 发布