#include<iostream>
#include<vector>
#include <cmath>
using namespace std;
int n, maxdepth=0, maxnum=0, temp, root;
vector <int> Next[100010];
void dfs(int index,int depth){
if(Next[index].size()==0){ //访问到叶结点
if(depth==maxdepth) maxnum++;
if(depth>maxdepth){
maxdepth=depth;
maxnum=1;
}
return;
}
for(int i=0;i<Next[index].size();i++){
dfs(Next[index][i],depth+1);
}
}
int main(){
double p,r;
cin>>n>>p>>r;
for(int i=0;i<n;i++){
scanf("%d",&temp);
if(temp==-1) {root=i;}
else{Next[temp].push_back(i);}
}
dfs(root,0);
printf("%.2f %d", p * pow(1 + r/100, maxdepth), maxnum);
system("pause");
return 0;
}
PAT 1090 Highest Price in Supply Chain (25 分)
最新推荐文章于 2024-07-25 09:34:23 发布