#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int N,countmax=0;
double rootprice,increment,price[100010],maxprice=0;
vector<int> child[100010];
void BFS(int root){
queue<int> q;
q.push(root);
price[root]=rootprice;
while(!q.empty()){
int t=q.front();
q.pop();
if(child[t].size()==0){
if(price[t]>maxprice){
maxprice=price[t];
countmax=1;
}else if(price[t]==maxprice){
countmax++;
}
}
for(int i=0;i<child[t].size();i++){
price[child[t][i]]=price[t]*(1.0+(0.01*increment));
q.push(child[t][i]);
}
}
}
int main(){
scanf("%d%lf%lf",&N,&rootprice,&increment);
int root;
for(int i=0;i<N;i++){
int temp;
scanf("%d",&temp);
if(temp!=-1) child[temp].push_back(i);
else root=i;
}
BFS(root);
printf("%.2f %d",maxprice,countmax);
return 0;
}
PAT A1090
最新推荐文章于 2019-08-16 10:45:08 发布