1090 Highest Price in Supply Chain(甲级)

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);
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/497049.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

微服务架构设计模式~识别系统操作

第一步&#xff1a;创建由关键类组成的抽象领域模型&#xff0c;这些关键类提供用于描述系统操作的词汇表&#xff1b; 第二步&#xff1a;确定系统操作&#xff0c;并根据领域模型描述每个系统操作的行为 领域模型主要源自用户故事中提及的名词&#xff0c;系统操作主要来自用…

Facebook、微软、谷歌三大研究巨头齐聚首,共同探讨人工智能发展现状和趋势

作者&#xff1a; 思颖、李诗概要&#xff1a;日前 AAAS 在 reddit 上组织了一场问答&#xff0c;Facebook 人工智能研究院 Yann LeCun&#xff0c;微软研究院院长 Eric Horvitz&#xff0c;谷歌研究总监 Peter Norvig 共同出席此次活动&#xff0c;回答了观众提出的一系列问题…

《大话设计模式》Python 版代码实现

From&#xff1a;http://www.cnblogs.com/wuyuegb2312/archive/2013/04/09/3008320.html 一、简单工厂模式 模式特点&#xff1a;工厂根据条件产生不同功能的类。 程序实例&#xff1a;四则运算计算器&#xff0c;根据用户的输入产生相应的运算类&#xff0c;用这个运算类处理具…

LeCun亲授的深度学习入门课:从飞行器的发明到卷积神经网络

Root 编译整理量子位 出品 | 公众号 QbitAI深度学习和人脑有什么关系&#xff1f;计算机是如何识别各种物体的&#xff1f;我们怎样构建人工大脑&#xff1f;这是深度学习入门者绕不过的几个问题。很幸运&#xff0c;这里有位大牛很乐意为你讲解。2月6日&#xff0c;UCLA&#…

微服务架构设计模式~根据业务能力进行服务拆分

业务能力定义了一个组织的工作 组织的业务能力通常是指这个组织的业务是做什么&#xff0c;它们通常是稳定的。 与之相反&#xff0c;组织采用何种方式来实现它的业务能力&#xff0c;是随着时间不断变化的。 识别业务能力 一个组织有哪些业务能力&#xff0c;是通过对组织的…

微服务架构设计模式~根据子域进行服务拆分

子域 领域驱动为每个子域定义单独的领域模型。子域是领域的一部分&#xff0c;领域是DDD中用来描述应用程序问题域的一个术语。识别子域的方式跟识别业务能力一样&#xff1a;分析业务并识别业务的不同专业领域&#xff0c;分析产出的子域定义结果也会跟业务能力非常接近。 限…

高通:全球NB-IoT/eMTC最新现状

来源&#xff1a;5G概要&#xff1a;全球NB-IoT/eMTC最新现状行业观察未来智能实验室是人工智能学家与科学院相关机构联合成立的人工智能&#xff0c;互联网和脑科学交叉研究机构。由互联网进化论作者&#xff0c;计算机博士刘锋与中国科学院虚拟经济与数据科学研究中心石勇、刘…

微服务架构设计模式~交互方式

一对一一对多同步模式请求/响应无异步模式 异步请求/响应 单向通知 发布/订阅 发布/异步响应 一对一的交互方式 1、请求/响应&#xff1a; 一个客户端向服务端发起请求&#xff0c;等待响应&#xff1b;客户端期望服务端很快就会发送响应。在一个基于线程的应用中&#xff0c…

1106 Lowest Price in Supply Chain(甲级)

1106 Lowest Price in Supply Chain (25分) A supply chain is a network of retailers&#xff08;零售商&#xff09;, distributors&#xff08;经销商&#xff09;, and suppliers&#xff08;供应商&#xff09;-- everyone involved in moving a product from supplier t…

2018年看好这些半导体企业

来源&#xff1a;钜亨网对半导体产业来说&#xff0c;去年是一个大年&#xff0c;无论哪个领域&#xff0c;都挣得盘满钵满。进入了2018&#xff0c;半导体产业将会面临哪些新状况&#xff1f;让我们来盘点一下&#xff01;DRAM今年供需稳定记忆体厂商持续获利的好年DRAM价格走…

AI黑箱:我们要用AI解释AI?

来源&#xff1a;亿欧概要&#xff1a;AI算法对人类生活的影响越来越大&#xff0c;但它们内部的运作往往是不透明的&#xff0c;人们对这种技术的工作方式也愈加感到担忧。AI算法对人类生活的影响越来越大&#xff0c;但它们内部的运作往往是不透明的&#xff0c;人们对这种技…

1053 Path of Equal Weigh(甲级)

1053 Path of Equal Weight (30分) Given a non-empty tree with root R, and with weight W ​i ​​ assigned to each tree node T ​i ​​ . The weight of a path from R to L is defined to be the sum of the weights of all the nodes along the path from R to any l…

美媒盘点DARPA的自然仿生项目

转自&#xff1a;“国防科技要闻”&#xff08;ID&#xff1a;CDSTIC&#xff09;作者&#xff1a;军事科学院军事科学信息研究中心 袁政英为了提高无人机蜂群效能&#xff0c;美空军已经开展对蝙蝠的研究。而DARPA的“生物技术办公室”也在试验一系列仿生项目&#xff0c;以获…

1110 Complete Binary Tree(甲级)

1110 Complete Binary Tree (25分) Given a tree, you are supposed to tell if it is a complete binary tree. Input Specification: Each input file contains one test case. For each case, the first line gives a positive integer N (≤20) which is the total number…

Thumbnails使用方法(图片处理工具类)

我们在java开发时&#xff0c;使用Thumbnails工具类能帮助我们对图片进行很好的处理&#xff0c;Thumbnails对图片的操作进行了很好的封装&#xff0c;往往很复杂的步骤能用一行代码就完成。 Thumbnails支持&#xff1a; 指定大小进行缩放 按照比例进行缩放 不按照比例&#…

浙江将建设超级高速公路,全面支持自动驾驶

来源&#xff1a;科技日报作者&#xff1a;江耘将建设的超级高速公路将具备智能、快速、绿色、安全的四大要素。浙江省要建设全国首条超级高速公路的说法于近日得到了官方证实。记者了解到&#xff0c;将建设的超级高速公路是已经分段批复的杭甬复线高速公路——杭绍甬高速公路…

Java消息服务~自动分配的消息头

消息头的值由JMS提供者来设置&#xff0c;开发者setJMSXxx()分配的值忽略。 JMSDestination 消息头使用一个Topic 或 Queue 对象来标识目的地。 Topic destination (Topic) message.getJMSDestination(); JMSDeliveryMode 在JMS 中&#xff0c;传送模式有两种类型&#xff1…

员工辞职的十大原因!

美国企管顾问史密斯&#xff08;Gregory Smith&#xff09;&#xff0c;日前在《CEO Refresher》杂志上指出&#xff0c;根据他多年的顾问经验&#xff0c;员工辞职的十大原因为&#xff1a; 1、员工的工作量过重&#xff0c;造成他们必须在晚上或周末加班。 2、公司…

1115 Counting Nodes in a BST(甲级)

1115 Counting Nodes in a BST (30分) A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes with keys less than or equal to the node’s key. The right subtree of …

Codeforces Round 917 (Div. 2)(A~D)(又是数学题)

A - Least Product 题意&#xff1a; 思路&#xff1a;若有奇数个负数&#xff0c;则不需要任何操作。若存在0&#xff0c;也不需要任何操作。其余情况将任意一个数改为0即可。 #include <bits/stdc.h> using namespace std; void solve() {int n;cin >> n;int …