- #define HAVE_STRUCT_TIMESPEC
- #include<bits/stdc++.h>
- using namespace std;
- int a[100007];
- vector<int>v[100007];
- int mx;
- int ans[100007];
- void dfs(int x,int storey){
- mx=max(mx,storey);
- ans[x]=storey;
- for(auto it:v[x])
- dfs(it,storey+1);
- }
- int main(){
- //iOS::sync_with_stdio(false);
- //cin.tie(NULL);
- //cout.tie(NULL);
- int n;
- int root=0;
- double p,r;
- cin>>n>>p>>r;
- for(int i=1;i<=n;++i){
- cin>>a[i];
- if(a[i]==-1)
- root=i-1;
- else
- v[a[i]].push_back(i-1);
- }
- dfs(root,0);
- int num=0;
- for(int i=0;i<n;++i){
- if(ans[i]==mx){
- ++num;
- }
- }
- double sum=p*pow(1+r/100.0,mx);
- printf("%.2lf %d",sum,num);
- return 0;
- }
来源: http://www.bubuko.com/infodetail-3297609.html