PAT甲级——A1106 Lowest Price in Supply Chain
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 (≤), 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:
Ki ID[1] ID[2] ... ID[Ki]
where in the i-th line, Ki 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. Kj 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 1.
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 <queue>
#include <cmath>
using namespace std;
int n, m;
double p, r;
int main()
{
cin >> n >> p >> r;
vector<vector<int>>people;
for (int i = ; i < n; ++i)
{
cin >> m;
vector <int>temp(m);
for (int i = ; i < m; ++i)
cin >> temp[i];
people.push_back(temp);
}
queue<int>node;
node.push();
int num = , level = -;
while (!node.empty())
{
queue<int>q;
while (!node.empty())
{
int root = node.front();
node.pop();
for (int i = ; i < people[root].size(); ++i)
q.push(people[root][i]);
if (people[root].size() == )//零售商
num++;
}
level++;
if (num > )
break;
node = q;
}
printf("%0.4f %d\n", p*pow((+r / ), level), num);
return ;
}
PAT甲级——A1106 Lowest Price in Supply Chain的更多相关文章
- PAT甲级——1106 Lowest Price in Supply Chain(BFS)
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90444872 1106 Lowest Price in Supp ...
- PAT 甲级 1106 Lowest Price in Supply Chain
https://pintia.cn/problem-sets/994805342720868352/problems/994805362341822464 A supply chain is a ne ...
- PAT A1106 Lowest Price in Supply Chain (25 分)——树的bfs遍历
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...
- A1106. Lowest Price in Supply Chain
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...
- PAT Advanced 1106 Lowest Price in Supply Chain (25) [DFS,BFS,树的遍历]
题目 A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)– everyone in ...
- PAT 甲级 1090 Highest Price in Supply Chain
https://pintia.cn/problem-sets/994805342720868352/problems/994805376476626944 A supply chain is a ne ...
- PAT甲级——A1090 Highest Price in Supply Chain
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...
- 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 ...
- PAT1106:Lowest Price in Supply Chain
1106. Lowest Price in Supply Chain (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CH ...
随机推荐
- Permission denied: user=root, access=WRITE, inode="/":hdfs:supergroup:drwxr-xr-x
通过手动安装CDH没权限 [root@slave1 ~]# groupadd supergroup[root@slave1 ~]# hadoop fs -mkdir /tao3^C[root@slav ...
- 纯css制作三级菜单
<!DOCTYPE html> <html> <head> <title>三级菜单</title> <meta charset=&qu ...
- 2019-8-31-C#-通过编程的方法在桌面创建回收站快捷方式
title author date CreateTime categories C# 通过编程的方法在桌面创建回收站快捷方式 lindexi 2019-08-31 16:55:58 +0800 201 ...
- 双十一HostGator独立服务器方案
一年一度的“双十一”购物狂欢节到来,各大电商平台线上消费的各种“吸金”开启了“双十一”模式,一年一度的“双十一”网购狂欢又开始以“巨大的价格优势”来勾起消费者的购买欲望. 此次双十一期间,HostGa ...
- Spring Boot环境搭建。
1.环境准备. jdk1.8 idea(如果不会激活可以看另外一篇:https://www.cnblogs.com/joeking/p/11119123.html) 2.打开idea 如果是idea的 ...
- HTML 5 基础
HTML 参考手册 HTML 5 视频 controls 属性供添加播放.暂停和音量控件. <video src="movie.ogg" width="320&qu ...
- MFC文档视图结构学习笔记
文档/视图概述 为了统一和简化数据处理方法,Microsoft公司在MFC中提出了文档/视图结构的概念,其产品Word就是典型的文档/视图结构应用程序 MFC通过其文档类和视图类提供了大量有关数据处理 ...
- duilib教程之duilib入门简明教程9.界面布局
上一个教程实现的标题栏代码中,并没有看到处理自适应窗口大小的代码,但是窗口大小变化后,按钮的位置会跟着变化,这是因为我们将按钮放到了HorizontalLayout.VerticalLayout,这样 ...
- hibernate_05_hibernateHQL查询QBC查询和SQL查询
1.HQL简介:HQL是Hibernate Query Language(Hibernate 查询语言)的缩写,提供更加丰富灵活.更为强大的查询能力:HQL更接近SQL语句查询语法.Hibernate ...
- arcmap分类标注问题
在给图层标注的时候,经常出现冲突后有些标注出不来,需要将某些个别的点要素进行标注位置调整,如下图: 处理步骤如下, (1)打开Maplex标注引擎.从ToolBars中打开Labeling工具,勾选U ...