###### 浙大PAT甲级 1090 广搜

AC代码：

#include<iostream>
#include<map>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<list>
#include<set>
#include<stack>
#include<cmath>
#include<vector>
#define ll long long
#define inf 999999999
using namespace std;
struct node
{
int id;
int lay;
};
vector<int> v[100000];
vector<node> vv;
bool cmp(node x,node y)
{
return x.lay>y.lay;
}
void bfs(int x)
{
queue<node> q;
node tmp;
tmp.id=x;
tmp.lay=0;
q.push(tmp);
vv.push_back(tmp);
while(!q.empty())
{
node rr=q.front();
q.pop();
for(int i=0;i<v[rr.id].size();i++)
{
node gg;
gg.id=v[rr.id][i];
gg.lay=rr.lay+1;
q.push(gg);
vv.push_back(gg);
}
}
}
int main()
{
int n;
double p,r;
scanf("%d %lf %lf",&n,&p,&r);
for(int i=0;i<n;i++)
{
int d;
scanf("%d",&d);
v[d].push_back(i);
}
bfs(-1);
sort(vv.begin(),vv.end(),cmp);
int ans=1;
for(int i=1;i<vv.size();i++)
{
if(vv[i].lay==vv[0].lay)
{
ans++;
}
}
double tt=(100+r)/100;
double hh=p*pow(tt,vv[0].lay-1);
printf("%.2lf %d",hh,ans);
}


#### PAT甲级1090

2017-01-29 23:29:05

#### 1090. Highest Price in Supply Chain (25)-PAT甲级真题

2016-08-14 21:08:13

#### PAT(甲级)1090

2015-09-29 11:07:07

#### 浙大PAT甲级 1100

2016-09-06 19:35:28

#### 浙大PAT考试1009~1012（1010是个神题。。）

2014-06-13 01:22:10

#### * 浙大PAT甲级 1043

2016-08-22 12:53:04

#### PAT(甲级)1025

2015-09-24 19:42:40

#### 浙大PAT甲级 1033

2016-08-21 13:48:01

#### PAT(甲级)1013

2015-09-23 16:35:01

#### 浙大 PAT 甲级1009

2016-10-14 20:53:34