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 ...
随机推荐
- 2018-8-10-win10-uwp-如何让一个集合按照需要的顺序进行排序
title author date CreateTime categories win10 uwp 如何让一个集合按照需要的顺序进行排序 lindexi 2018-08-10 19:16:50 +08 ...
- 数据库MySQL--连接查询
例子文件1:https://files.cnblogs.com/files/Vera-y/myemployees.zip 例子文件2:https://files-cdn.cnblogs.com/fil ...
- 学习修复Laravel The only supported ciphers are AES-128-CBC and AES-256-CBC
The only supported ciphers are AES-128-CBC and AES-256-CBC 在项目中,删除了 .env的APP_KEY的值,再运行 php artisan k ...
- mysql Slave 启动失败
报错日志 Slave failed to initialize relay log info structure java程序访问日志显示事物查询失败,排查mysql 发现其中一台slave 启动状态 ...
- Windows 10 连接服务器
{ windows + r input mstsc } { //mstsc D:\TOOL\Servers.rdp /v 127.0.0.1:9998 }
- SDOI2018
SD的题有点反人类啊... d1t1[SDOI2018]物理实验 感觉比较好想但不太好写,写了一半弃了 d1t2[SDOI2018]战略游戏 建出圆方树,每次建虚树,答案就是虚树上的原点个数减去询问的 ...
- 同一个tomcat 两个项目 互相访问接口方法
package com.qif.xdqdm.util; import com.alibaba.fastjson.JSONObject; import java.io.*; import java.ne ...
- error C2712: Cannot use __try in functions that require object unwinding
转自VC错误:http://www.vcerror.com/?p=52 问题描述: error C2712: Cannot use __try in functions that require ob ...
- nginx实用配置用例
vue项目部署及后台api访问 nginx.conf # vue本地项目配置 ... server { listen 8000; server_name localhost; root /.../di ...
- USACO 2013 January Silver Painting the Fence /// oj23695
题目大意: 输入n,k :n次操作 找到覆盖次数在k及以上的段的总长 一开始位置在0 左右活动范围为1-1000000000 接下来n行描述每次操作的步数和方向 Sample Input 6 22 R ...