1106 Lowest Price in Supply Chain(甲级)

1106 Lowest 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. Only the retailers will face the customers. 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 lowest price a customer 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 their ID’s are numbered from 0 to N−1, and the root supplier’s ID is 0); P, the price given by the root supplier; and r, the percentage rate of price increment for each distributor or retailer. Then N lines follow, each describes a distributor or retailer in the following format:
K
​i
​​ ID[1] ID[2] … ID[K
​i
​​ ]
where in the i-th line, K
​i
​​ is the total number of distributors or retailers who receive products from supplier i, and is then followed by the ID’s of these distributors or retailers. K
​j
​​ being 0 means that the j-th member is a retailer. All the numbers in a line are separated by a space.
Output Specification:

For each test case, print in one line the lowest price we can expect from some retailers, accurate up to 4 decimal places, and the number of retailers that sell at the lowest price. There must be one space between the two numbers. It is guaranteed that the all the prices will not exceed 10
​10
​​ .
Sample Input:

10 1.80 1.00
3 2 3 5
1 9
1 4
1 7
0
2 6 1
1 8
0
0
0
Sample Output:

1.8362 2

#include<iostream>
#include<vector>
#include<math.h>
using namespace std;
const int maxn = 100001;
struct info {//定义静态树vector<int>v;
}node[maxn];
int n;
double p, r;
int min_level = 0x7f7f7f7f;//一般定义最大值为0x7f7f7f7f,求最小深度
int num = 0;//记录相同深度的节点数
void dfs(int root, int depth)
{if (node[root].v.size() == 0){if (min_level > depth){min_level = depth;num = 1;}else if (min_level == depth){num++;}return;}for (int i = 0; i < node[root].v.size(); i++){dfs(node[root].v[i], depth + 1);}
}
int main()
{cin >> n >> p >> r;r /= 100;for (int i = 0; i < n; i++){int k;cin >> k;for (int j = 0; j < k; j++){int value;cin >> value;node[i].v.push_back(value);}}dfs(0, 0);printf("%.4lf %d", p * pow((1 + r), min_level), num);
}

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

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

相关文章

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 …

权威发布:新一代人工智能发展白皮书(2017)

来源&#xff1a;机器人大讲堂指导单位、专家顾问及编写人员顾 问潘云鹤 中国工程院院士指导单位工业和信息化部信息化和软件服务业司指导委员会谢少锋 工信部信软司司长李冠宇 工信部信软司副司长徐晓兰 中国电子学会副理事长兼秘书长张宏图 中国电子学会总部…

Python 的 Gevent --- 高性能的 Python 并发框架

From&#xff1a;http://www.xuebuyuan.com/1604603.html Gevent 指南(英文)&#xff1a;http://sdiehl.github.io/gevent-tutorial Gevent 指南(中文)&#xff1a;http://xlambda.com/gevent-tutorial Gevent 指南(中文)下载地址&#xff1a;http://download.csdn.net/downloa…

AJAX Control Toolkit 控件学习(转自csdn山巅)

AJAX Control Toolkit 控件学习 2006-1-16 ToggleButton 关联ASP.NET CheckBox控件 RoundedCorder 造就圆角框 PasswordStrength TextBox中输入数据长度&#xff0c;以及限制&#xff1b;非常智能&#xff0c;有提示图 DropShadow 造就了照片的背影效果。 ScrollManag…

高通首次推出AI引擎 打包所有软硬件算力

来源&#xff1a;智东西作者&#xff1a;明天2月22日消息&#xff0c;高通宣布推出人工智能引擎&#xff08;AI Engine&#xff09;&#xff0c;让人工智能在终端侧&#xff08;如智能手机&#xff09;上的应用更快速、高效。该AI Engine包括软硬件两部分&#xff0c;在高通骁龙…

Java消息服务~开发者分配的消息头

生产者传送该消息之前在Message 对象上设置 JMSReplyTo 有些情况下&#xff0c;一个JMS消息生产者可能会要求消费者对一条消息做出应答。JMSReplyTo 消息头包含了一个javax.jms.Destination&#xff0c;标明了JMS 消费者应该应答的地址。请注意&#xff1a;如果某条消息头属性…

基金小窍门:如何判断基金的赚与赔

基金申购的时候&#xff0c;除了货币型基金&#xff0c;都有申购费,一般为申购金额的1.5%。 赎回的时候有赎回的手续费&#xff0c;一般为赎回金额的0.5%; 你只要记住两个单位净值就可以了&#xff1a;申购当日的基金单位净值&#xff08;记做x&#xff09;&#xff0c…

python Lambda 表达式

来源:http://www.cnblogs.com/jydeng/p/4145188.html 一、lambda函数 1、lambda函数基础&#xff1a; lambda函数也叫匿名函数&#xff0c;即&#xff0c;函数没有具体的名称,而用def创建的方法是有名称的。如下&#xff1a; """命名的foo函数"""…

一文详解「群体机器人」中的「实体进化」到底是什么?

原文来源&#xff1a;frontiers作者&#xff1a;Nicolas Bredeche、Evert Haasdijk、Abraham Prieto「雷克世界」编译&#xff1a;嗯~阿童木呀、KABUDA本文概述了适用于机器人群体&#xff08;robot collectives&#xff09;在线分布式进化的进化机器人技术&#xff0c;即实体进…

Java消息服务~JMSReplyTo示例

在下面的例子中&#xff0c;首先创建两个Queue&#xff0c;发送者给一个Queue发送&#xff0c;接收者接收到消息之后给另一个Queue回复一个Message&#xff0c;然后再创建一个消费者来接受所回复的消息 import javax.jms.Connection; import javax.jms.JMSException; impo…