标签:using div mes lib push return class vector a10
#include <bits/stdc++.h> #include <stdio.h> #include <stdlib.h> #include <queue> using namespace std; const int maxn = 100010; vector<int> child[maxn]; double p,r; int n,maxDepth = 0,num = 0; void DFS(int index,int depth){ if(child[index].size() == 0){ if(depth > maxDepth){ maxDepth = depth; num = 1; }else if(depth == maxDepth){ num++; } return; } for(int i =0;i<child[index].size();++i){ DFS(child[index][i],depth+1); } } int main(){ int father,root; scanf("%d%lf%lf",&n,&p,&r); r /= 100; for(int i=0;i<n;++i){ scanf("%d",&father); if(father != -1){ child[father].push_back(i); }else{ root = i; } } DFS(root,0); printf("%.2f %d\n",p * pow(1+r,maxDepth),num); system("pause"); return 0; }
树的遍历——A1090 Highest Price in Supply Chain(25)(使用vector<Int> temp[maxn]来当作树)
标签:using div mes lib push return class vector a10
原文地址:https://www.cnblogs.com/JasonPeng1/p/12234711.html