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<cstdio>
#include<cmath>
#include<vector>
using namespace std;
const int maxn = ;
vector<int> child[maxn];
int n,maxDepth = ,num = ;
double p,r; void DFS(int index,int depth){
if(child[index].size() == ){
if(depth > maxDepth){
maxDepth = depth;
num = ;
}else if(depth == maxDepth){
num++;
}
return;
}
for(int i = ; i < child[index].size(); i++){
DFS(child[index][i],depth+);
}
} int main(){
scanf("%d%lf%lf",&n,&p,&r);
int father,root;
r /= ;
for(int i = ; i < n; i++){
scanf("%d",&father);
if(father != -){
child[father].push_back(i);
}
else{
root = i;
}
}
DFS(root,);
printf("%.2f %d\n",p*pow(+r,maxDepth),num);
return ;
}

1090 Highest Price in Supply Chain (25)(25 分)的更多相关文章

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

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

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

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

  3. 1090 Highest Price in Supply Chain (25 分)(树的遍历)

    求所有叶节点中的最高价以及这个价格的叶节点个数 #include<bits/stdc++.h> using namespace std; ; vector<int>mp[N]; ...

  4. PAT 1090 Highest Price in Supply Chain[较简单]

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

  5. [建树(非二叉树)] 1090. Highest Price in Supply Chain (25)

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

  6. 1090 Highest Price in Supply Chain——PAT甲级真题

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

  7. 1090. Highest Price in Supply Chain (25) -计层的BFS改进

    题目如下: A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyon ...

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

    时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A supply chain is a network of r ...

  9. PAT Advanced 1090 Highest Price in Supply Chain (25) [树的遍历]

    题目 A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)–everyone inv ...

随机推荐

  1. Oracle——无法在查询中执行 DML 操作

    今天在调用Oracle Function遇到一个异常

  2. serviceBehaviors_dataContractSerializer_maxItemsInObjectGraph 关键**Behavior

    <behaviors> <serviceBehaviors> <behavior name="STHotel.Product.WCFService.HotelP ...

  3. tp5 修改配置参数 view_replace_str 无效

    原因: 缓存问题 找到  thinkphp\library\think\Template.php 找到  public function fetch($template, $vars = [], $c ...

  4. nginx 是如何分配 worker 进程连接数的

    客户端连接过来后,多个空闲的进程,会竞争这个连接,很容易看到,这种竞争会导致不公平,如果某个进程得到 accept 的机会比较多,它的空闲连接很快就用完了,如果不提前做一些控制,当 accept 到一 ...

  5. p7.BTC-挖矿总结

    全节点: 1 一直在线 2 在本地硬盘上维护完全的区块链信息 3 在内存里维护UTXO集合,以便快速检验交易的正确性 4 监听比特币网络上的交易信息,验证每个交易的合法性 5 决定哪些交易会被打包到区 ...

  6. Django admin 页面中文名称加s,去除s的设置

    class UserInfo(models.Model): #字段 #字段 #字段 class Meta: verbose_name_plural = '用户列表'

  7. 资源管理与调度系统-YARN的资源调度器

    资源管理与调度系统-YARN的资源调度器 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 资源调度器是Hadoop YARN中最核心的组件之一,它是ResourceManager中的 ...

  8. 运维开发笔记整理-django日志配置

    运维开发笔记整理-django日志配置 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Django日志 Django使用python内建的logging模块打印日志,Pytho ...

  9. Django - 读取Excel文件

    目录 返回Django目录 返回随笔首页 没么多事儿,来看示例: 前端重要代码. <div class="row"> <div> <form acti ...

  10. 小程序框架之视图层 View~基础组件

    框架为开发者提供了一系列基础组件,开发者可以通过组合这些基础组件进行快速开发.详细介绍请参考组件文档. 什么是组件: 组件是视图层的基本组成单元. 组件自带一些功能与微信风格一致的样式. 一个组件通常 ...