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

1106 Lowest Price in Supply Chain(甲级)相关推荐

  1. PAT甲级1106 Lowest Price in Supply Chain:[C++题解]树、结点到根结点的距离、树形dp、记忆化搜索

    文章目录 题目分析 题目链接 题目分析 来源:acwing 分析:这道题是第三次做了. 和PAT甲级1079 Total Sales of Supply Chain:[C++题解] 树.结点到根结点的 ...

  2. 1106 Lowest Price in Supply Chain

    1. 本题和1090 Highest Price in Supply Chain适成对比,都是先构建一棵树,但本题是求最小层数和个数,链接题是求最大层数和个数.在极值更换和个数更新方面,两道题是一样的 ...

  3. PAT甲级 -- 1106 Lowest Price in Supply Chain (25 分)

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

  4. 1106. Lowest Price in Supply Chain (25)-PAT甲级真题(dfs,bfs,树的遍历)

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

  5. 1106 Lowest Price in Supply Chain (25)

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

  6. PAT甲题题解-1106. Lowest Price in Supply Chain (25)-(dfs计算树的最小层数)

    统计树的最小层数以及位于该层数上的叶子节点个数即可. 代码里建树我用了邻接链表的存储方式--链式前向星,不了解的可以参考,非常好用: http://www.cnblogs.com/chenxiwenr ...

  7. PAT_A1106#Lowest Price in Supply Chain

    Source: PAT A1106 Lowest Price in Supply Chain (25 分) Description: A supply chain is a network of re ...

  8. 1090 Highest Price in Supply Chain(甲级)

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

  9. 【PAT】A1106 Lowest Price in Supply Chain

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

最新文章

  1. 38 JavaScript中的this指向问题
  2. PM配置详解之二:工厂维护和客户服务中心的主数据
  3. 使用kubernetes的deployment进行RollingUpdate
  4. linux介绍及目录结构(一)
  5. SAP中事务代码ME2N中引出的表格里,仍要Invoice数量是什么含义?
  6. python 面向对象教程:访问限制
  7. 【小白学PyTorch】11.MobileNet详解及PyTorch实现
  8. 南方日报专访 | 网易云信沈青松: 企业上云正热,PaaS将迎来爆发
  9. 大家心目中的这些「优质」论文,你读过几篇?| PaperDaily #01
  10. sci translate好用吗_228个学科分类对应12000+本SCI和SSCI期刊,总有你要的那款!
  11. java ee ide 添加spring,如何在Eclipse IDE项目文件夹中为spring添加jar文件
  12. wordpress插件-WP Rocket3.8.8与Rocket3.9.1双版本/火箭缓存插件免授权汉化版
  13. PHP读取某站点的链接的函数
  14. django 不包括字段 序列化器_DRF比Django的认证和权限高在哪里
  15. 管理感悟:不要做自己想做的事情
  16. git merge/git rebase分支合并
  17. hitool java_Hitool打开出现failed to create the java virtual machine
  18. 阿里P7亲自教你!昆明java招聘信息
  19. 【技术讨论】从弹弹堂说起,如何用2D物理引擎编写一个游戏lt;一gt;2011-11-05 10:36
  20. Lan9252-FPGA调试笔记

热门文章

  1. 基于Flask+Nginx+uWSGI实现CentOS服务端模型部署及预加载
  2. KD Tree的原理及Python实现
  3. 解决AndroidStudio添加ProjectLibary后在编译时遇到的各种问题之解决方式索引(finished with non-zero exit value and so on...)
  4. Python中的 List
  5. 短期记忆容量必需有限
  6. python 约束与异常处理
  7. 如何在终端编译C++代码
  8. 菜鸟的Xamarin.Forms前行之路——绪言
  9. 多线程的单元测试工具 - GroboUtils
  10. linux的系统移植——交叉编译器