#include<stdio.h>
#include<vector>
#include<cmath>
using namespace std;
int maxdepth = 0, num = 0;//num =0而不是1
vector<int> child[100010];
void dfs(int root, int depth){
if(child[root].size() == 0){
if(depth == maxdepth){
num++;
}
else if(depth > maxdepth){
maxdepth = depth;
num = 1;
}
return;
}
for(int i = 0; i < child[root].size(); i++){
dfs(child[root][i], depth + 1);
}
}
int main(){
int n,root;
double p,r;
scanf("%d%lf%lf", &n, &p, &r);
for(int i = 0; i < n; i++){
int father;
scanf("%d", &father);
if(father != -1){
child[father].push_back(i);
}else{
root = i;
}
}
dfs(root, 0);
printf("%.2f %d", p * pow((r / 100) + 1, maxdepth), num);
return 0;
}
第一次,参考算法笔记完成