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: (
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
Sample
Input:
1 | 9 1.80 1.00 |
Output:
1 | 1.85 2 |
Solution
例子可以抽象为如下所示的一颗树
1 | 4 |
供应链是一个有向无环图,可以抽象为一棵树。本题主要是为了求树的高度以及最后一层树的节点数,采用层序遍历(BFS)即可。注意一点是,float 的表示范围无法到达
Code
1 |
|
- 本文标题:1090 Highest Price in Supply Chain (25分)
- 本文作者:codeflysafe
- 创建时间:2020-03-10 11:45:51
- 本文链接:https://codeflysafe.github.io/2020/03/10/2020-03-10-1090-Highest-Price-in-Supply-Chain-(25分)/
- 版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!