1090 Highest Price in Supply Chain (25 分)

1090 Highest Price in Supply Chain (25 分)【dfs】 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 th... 阅读详情

在这里插入图片描述
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<iomanip>
#include<cmath>
using namespace std;
vector<int> S[100005];
int maxdepth=0, maxnum = 0;
void dfs(int s, int depth) {
	if (S[s].size() == 0) {
		if (maxdepth == depth) maxnum++;
		if (maxdepth < depth) {
			maxdepth=depth;
			maxnum = 1;
		}
		return;
	}
	for (int i = 0; i < S[s].size(); i++)
		dfs(S[s][i], depth + 1);
}
int main() {
	int N;
	double P, r;
	cin >> N >> P >> r;
	int root;
	for (int i = 0; i < N; i++) {
		int s;
		cin >> s;
		if (s == -1) {
			root = i;
		}
		else {
			S[s].push_back(i);
		}
	}
	dfs(root, 0);
	cout << fixed << setprecision(2) << P * pow(1 + r / 100, maxdepth);
	cout << " ";
	cout << maxnum;
	return 0;
}
合肥工业大学操作系统实验9 依据操作系统课程所介绍的页面置换算法与动态内存分配的原理,本实验的目的是掌握OPT、FIFO、LRU、LFU、Clock等页面置换算法;掌握可用空间表及分配方法;掌握边界标识法以及伙伴系统的内存分配方法和回收方法。从而深入理解操作系统的内存管理。从而加深对教材上页面置换算法与动态内存分配的理解。 阅读详情

相关推荐

数字IC设计之时序分析基础概念汇总

时序分析主要有两种办法:静态时序分析: (static timing analysis,STA),是遍历电路存在的所有时序路径,根据给定工作条件(PVT)下的时序库.lib文件计算信号在这些路径上的传播延时,检查信号的建立和保持时间是否满足约束要求,根据最大路径延时和最小路径延时找出违背时序约束的错误。

weixin_45230720的博客 5607

1090 Highest Price in Supply Chain (25分)

1 题目 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. St...

韩江雪de 小屋 533

Virtualbox “Kernel driver not installed (rc=-1908)”问题全面解析与修复指南

本文全面解析了Virtualbox出现'Kernel driver not installed (rc=-1908)'错误的原因及修复方法。详细介绍了如何通过重新安装virtualbox-dkms、处理Secure Boot特殊情况等步骤解决该问题,并提供了预防措施与最佳实践,帮助用户避免类似错误再次发生。

weixin_30352645的博客 530

1090 Highest Price in Supply Chain (25 分)

1090Highest 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. Star...

chen_zan_yu_的博客 161

同花顺客户端数据采集:Hook注入与内存解密实战

在金融量化领域,客户端数据采集是获取低延迟、高精度行情的关键技术路径。其底层涉及进程通信、内存加密、反调试等典型Windows逆向工程问题。理解API Hook原理与AES-CBC动态密钥派生机制,有助于突破传统HTTP爬虫在国产金融软件中的失效困境。该技术不依赖网络劫持,而聚焦于本地进程内函数拦截与运行时内存解析,具备离线、可控、合规等工程优势,广泛应用于Level2行情、逐笔委托、分笔成交等高频数据场景,是量化基础设施中‘端侧数据主权’的重要实现方式。

weixin_30496999的博客 856

Marvell 88E6390x交换芯片:从零构建No-CPU模式网络交换系统

本文详细介绍了如何为Marvell 88E6390x以太网交换芯片构建No-CPU模式网络交换系统。通过解析其核心价值与硬件准备,并手把手指导使用CodeBlocks、IMPGUI和SwitchGUI等软件工具进行配置代码编写、镜像生成与烧录,最终实现交换芯片脱离外部CPU独立工作,适用于成本敏感、空间受限的嵌入式网络设备设计。

plant的博客 483

【1090】Highest Price in Supply Chain (25 分)

#include<iostream> #include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> #include<algorithm> #include<map> #include<vector> #inclu...

发现问题,并解决问题,批判性思维 540

pytest-bdd封装

简介 pytestbdd主要是用于代码封装 代码封装的好处: 1、提升代码复用率 2、提示测试效率 手工测试–使用框架0代码 流程+数据驱动 产品经理这样的不懂测试的人员–流程驱动 自动化测试–数据驱动 pytest-bdd:流程驱动封装 行为驱动–敏捷开发模式,消除开发/测试对需要了解的歧义 使用方式: 描述需求/用户场景 Feature(需求) Scenario(场景) Given(假设) When(操作步骤) Then(验证,清除) #新建feature 文件之前 需要提取安装支持featrue文.

liao_11的博客 2733

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 th...

weixin_33832340的博客 128

31、贝叶斯认知建模与隐马尔可夫模型:理论与应用

本文探讨了贝叶斯认知建模与隐马尔可夫模型(HMM)的理论基础及其在认知科学和神经科学中的应用。重点介绍了贝叶斯定理和HMM的基本原理,并结合实际案例,如情绪识别系统和脑机接口(BCI),展示了它们在处理复杂认知任务中的强大能力。文章还讨论了贝叶斯-HMM模型的技术细节、优势与局限性,以及未来的发展前景。

meat5的博客 141

基于LUT表对鱼眼图像进行畸变校正

当然也可以进行图像的畸变校正操作,已知相机的焦距为fx/fy,光心为cx/cy,像素大小为p(单位mm/pixel)对于畸变校正结果图中像素点(u,v),其对应的原图中的像素坐标(u',v')的计算流程描述如下。1)假设无畸变相机成像模型的焦距和光心与原相机相同,计算得到无畸变相机成像模型中归一化平面坐标(X,Y,Z),其中X=(u-cx)/fx,Y=(v-cy)/fy,Z=1。这里x'/y'的单位为像素。

On my way 639

PAT 1090 Highest Price in Supply Chain (25 分)

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. Starti...

peanWang的博客 249

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

BFS_1090 Highest Price in Supply Chain (25 分)

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. Star...

A_Bo的博客 450

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

PAT1090 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 a

Little_Small_Joze的博客 300

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

1090 Highest Price in Supply Chain (25 分)bfs

#include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;cstdio&gt; #include &lt;queue&gt; #include &lt;cstring&gt; using namespace std; const int maxn = 2e5 + 6; typedef struct P {     int  ...

lxy 202

【PAT甲级】1090 Highest Price in Supply Chain (25分)

解题过程的小记录,如有错误欢迎指出。 难度:三星(与上一题很像) 小导航~题目分析注意点我的解题过程思路bug代码dalao的代码借鉴点 题目分析 供应商的商品每经过一个经销商就要进行价格涨幅,经过几层(或者没有)经销商的转手到零售商的手里,求我们能从零售商手中买到的最贵的商品价格(其实也就是求树的深度) 注意点 找出最大价钱要在DFS中找,不要出来再进行排序,会有两个测试点超时 我的解题过程 思路 设置一个结构体node存储价钱和结点孩子 按照题设为结构体数组赋值 用DFS求出每个结点的价格,找出最高的

SpicyChicken的自我修养 330

1090 Highest Price in Supply Chain (25 分)——PAT A

1090Highest 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. Star...

weixin_42769575的博客 224
上一篇: 1094 The Largest Generation (25 分)
下一篇: 1079 Total Sales of Supply Chain (25 分)
好想当依蕾娜小姐的狗
博客等级 码龄7年 0粉丝 62原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值