#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
const int maxn = 100010;
vector<int> child[maxn];
int n;
double P, R;
int maxdepth = 0,num=0;
void dfs(int root,int depth)
{
if (child[root].size() == 0)
{
if (depth > maxdepth)
{
num = 1;
maxdepth = depth;
}
else if (depth == maxdepth) num++;
return;
}
for (int i = 0; i < child[root].size() ; i++)
{
dfs(child[root][i], depth + 1);
}
}
int main()
{
int temp,root;
scanf("%d %lf %lf", &n, &P, &R);
for (int i = 0; i < n; i++)
{
scanf("%d", &temp);
if (temp != -1) child[temp].push_back(i);
else root = i;
}
dfs(root, 0);
printf("%.2f %d\n", P*pow((1 + R/100), maxdepth), num);
return 0;
}
A1090 Highest Price in Supply Chain (25 分)dfs
最新推荐文章于 2021-03-06 15:09:08 发布