A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.

Starting from one root supplier, everyone on the chain buys products from one's supplier in a price P and sell or distribute them in a price that is r% higher than P. It is assumed that each member in the supply chain has exactly one supplier except the root supplier, and there is no supply cycle.

Now given a supply chain, you are supposed to tell the highest price we can expect from some retailers.

Input Specification:

Each input file contains one test case. For each case, The first line contains three positive numbers: N (≤10​5​​), the total number of the members in the supply chain (and hence they are numbered from 0 to N−1); P, the price given by the root supplier; and r, the percentage rate of price increment for each distributor or retailer. Then the next line contains N numbers, each number S​i​​ is the index of the supplier for the i-th member. S​root​​ for the root supplier is defined to be −1. All the numbers in a line are separated by a space.

Output Specification:

For each test case, print in one line the highest price we can expect from some retailers, accurate up to 2 decimal places, and the number of retailers that sell at the highest price. There must be one space between the two numbers. It is guaranteed that the price will not exceed 10​10​​.

Sample Input:

9 1.80 1.00
1 5 4 4 -1 4 5 3 6

Sample Output:

1.85 2

#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
vector<int>v[100001];
int maxnum=0,maxdepth=0;
void dfs(int index,int depth)
{if(v[index].size()==0){if(maxdepth==depth)maxnum++;///If you find a quantity with the same height, add one.else if(maxdepth<depth){maxdepth=depth;maxnum=1;}///If you find something deeper, update two values.}for(int i=0;i<v[index].size();i++)dfs(v[index][i],depth+1);
}
int main()
{int n,jojo,root;double p,r;cin>>n>>p>>r;for(int i=0;i<n;i++){cin>>jojo;if(jojo==-1)root=i;elsev[jojo].push_back(i);}dfs(root,0);printf("%.2f %d",p*pow(1+r/100,maxdepth),maxnum);
}

1090 Highest Price in Supply Chain(天上人间,潇潇共雨。曼珠红遍,流水忘川。)相关推荐

  1. PAT甲级1090 Highest Price in Supply Chain:[C++题解]树、结点到根结点的距离、记忆化搜索、树形dp

    文章目录 题目分析 题目链接 题目分析 来源:acwing 和PAT甲级1079 Total Sales of Supply Chain:[C++题解] 树.结点到根结点的距离.树形dp.记忆化搜索是 ...

  2. 1090 Highest Price in Supply Chain(甲级)

    1090 Highest Price in Supply Chain (25分) A supply chain is a network of retailers(零售商), distributors ...

  3. 1090 Highest Price in Supply Chain (25 分)

    1090 Highest Price in Supply Chain (25 分) A supply chain is a network of retailers(零售商), distributor ...

  4. PAT甲级 -- 1090 Highest Price in Supply Chain (25 分)

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

  5. 1090 Highest Price in Supply Chain (25)(25 分)

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

  6. 1090. Highest Price in Supply Chain (25)

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

  7. 1090 Highest Price in Supply Chain (25)

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

  8. 1090 Highest Price in Supply Chain (25 分)(模拟建树,找树的深度)牛客网过,pat没过...

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

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

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

最新文章

  1. 图解 Git 工作原理
  2. .net multi-threads synchronization : Use Lock effective
  3. 参数binlog_row_image设置MINIMAL,你今天被坑了吗?
  4. python+OpenCv+dlib实现人脸68个关键点检测
  5. python详细安装教程linux-python 在linux系统的安装教程
  6. PyTorch基础(一)-----张量(Tensor)
  7. double 四舍五入保留一定的位数
  8. matlab multithreading spyder,spyder和python的关系是什么
  9. javascript变量提升/函数提升
  10. dbml mysql_MySQL数据库笔记二:数据类型及数据库操作
  11. 从JavaScript预编译看function的生存时间
  12. 《点石成金:访客至上的Web和可用性设计秘笈(原书第3版)》--- 读书笔记
  13. 史上最好用的GIF工具——ScreenToGif
  14. freeswitch 解决方案之视频会议
  15. 刻录DVD9光盘内容至DVD5 DVD-R盘指南
  16. BUU Dest0g3 520迎新赛 WEB writeup
  17. 秒杀抢红包的思考和总结
  18. 容器类存储表格数据(12)
  19. 小米电视是鸿蒙系统吗,搭载鸿蒙系统!华为正式发布荣耀智慧屏 小米电视迅速升级取消开机广告...
  20. 光的反射规律: 反射光线、入射光线和法线

热门文章

  1. yii2.0域名目录绑定(二级域名)以及url美化 url伪静态 Apache ,Ngnix和 IIS
  2. win10共享计算机win7,Win7系统和win10系统设置共享打印机的方法
  3. 读《禅与摩托车维修艺术》
  4. 实现文字色彩渐变(Mask)
  5. 【WebServerProgramming】Ch.1 网络因特网Web
  6. linux内核编译详解
  7. 基于TCP Socket和Websocket实现的相互即时通信系统
  8. 基于ISTQB定义理解软件测试
  9. 史上最强!目标检测数据集标注工具网页版
  10. 超实用:数字金额转成人民币大写