1090 Highest Price in Supply Chain (25分)
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<vector>
#include<math.h>
using namespace std;
const int maxn = 100010;
int n;
double p, r;
double sum = 0;
struct info {//定义静态树double data;//货物量vector<int>v;//孩子节点
}node[maxn];
int num = 0;//相同深度的数量
int max_depth = 0;//最大深度
void dfs(int root, int depth)
{if (node[root].v.size() == 0)//到达叶子节点{if (max_depth == depth){num++;}else if(max_depth<depth){max_depth = depth;num = 1;}return;}for (int i = 0; i < node[root].v.size(); i++){dfs(node[root].v[i], depth + 1);//递归访问子节点}
}
int main()
{cin >> n >> p >> r;int child;int root;r /= 100;for (int i = 0; i < n; i++){cin >> child;if (child != -1){node[child].v.push_back(i);}else{root = i;}}dfs(root, 0);printf("%.2lf %d", p * pow(1 + r, max_depth),num);
}

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 (25 分)

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

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

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

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

    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(天上人间,潇潇共雨。曼珠红遍,流水忘川。)

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

最新文章

  1. 来看看企业如何拥抱混合云?
  2. java 请求响应_java http接口请求响应 request response
  3. Java多线程之CAS缺点
  4. 数据库设计笔记——概述(一)
  5. Docker添加或者更改容器的端口映射
  6. python读取字典元素笔记_Python 学习笔记 - 字典
  7. Linux系列-Red Hat5平台下的DHCP服务搭建
  8. 动态规划1——生产线调度问题(Dynamic Programming)
  9. 解决jQuery中dbclick事件触发两次click事件
  10. 静态初始化--我的理解
  11. centos7通过阿里云配置docker加速镜像
  12. LabVIEW编程LabVIEW开发Keithley 6485例程与相关资料
  13. 中国气候分布矢量图_如何用30行代码构建气候图
  14. GridView使用大全
  15. App Store2016年最新审核规则
  16. 程序员常用远程工具有哪些?
  17. 数据结构-第一讲 基本概念-学习笔记(MOOC 浙江大学 陈越 何钦铭)
  18. dss数字签名技术java_DSS数字签名标准
  19. Android中日志打印 Log的使用
  20. 那些花儿!吉他简谱~

热门文章

  1. 论文浅尝 - SIAM ICDM 2020 | 基于图时空网络的知识引导的诊断预测
  2. Android官方开发文档Training系列课程中文版:高效显示位图之加载大位图
  3. promise ,async 小记
  4. OO第四单元——UML及其解析器——总结 暨 OO课程大总结
  5. eclipse中monokai插件的安装
  6. Linux系统中的load average
  7. 【转】 VC MFC 钩子 实现 自绘 窗体 标题栏 非客户区
  8. Run-time system与虚拟机
  9. linux的基础知识——IP,UDP和TCP
  10. python科学计算三剑客_机器学习三剑客之Numpy