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 (<=105), 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 1010.

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<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef struct NODE{
vector<int>child;
}node;
int N, cnt = ;
double P, r, lowSum = ;
node tree[];
void dfs(int root, int depth){
if(tree[root].child.size() == ){
double ans = ;
ans = P * pow(1.0 + r, depth);
if(ans < lowSum){
cnt = ;
lowSum = ans;
}else if(ans == lowSum){
cnt++;
}
return;
}
int len = tree[root].child.size();
for(int i = ; i < len; i++){
dfs(tree[root].child[i], depth + );
}
}
int main(){
scanf("%d%lf%lf", &N, &P, &r);
r = r / 100.0;
for(int i = ; i < N; i++){
int tempc;
scanf("%d", &tempc);
if(tempc != ){
int tempd;
for(int j = ; j < tempc; j++){
scanf("%d", &tempd);
tree[i].child.push_back(tempd);
}
}
}
dfs(, );
printf("%.4f %d", lowSum, cnt);
cin >> N;
return ;
}

A1106. Lowest Price in Supply Chain的更多相关文章

  1. PAT A1106 Lowest Price in Supply Chain (25 分)——树的bfs遍历

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

  2. PAT甲级——A1106 Lowest Price in Supply Chain

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

  3. 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 ...

  4. PAT1106:Lowest Price in Supply Chain

    1106. Lowest Price in Supply Chain (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CH ...

  5. [建树(非二叉树)] 1106. Lowest Price in Supply Chain (25)

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

  6. PAT甲级——1106 Lowest Price in Supply Chain(BFS)

    本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90444872 1106 Lowest Price in Supp ...

  7. 1106. Lowest Price in Supply Chain (25)

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

  8. PAT 甲级 1106 Lowest Price in Supply Chain

    https://pintia.cn/problem-sets/994805342720868352/problems/994805362341822464 A supply chain is a ne ...

  9. PAT 1106 Lowest Price in Supply Chain

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

随机推荐

  1. idea打包springboot+maven项目并发布在linux上

    2018年11月13日我亲测有效的,很简单的,借鉴博客:https://blog.csdn.net/smilecall/article/details/56288972 第一步:随便建一个maven类 ...

  2. 在linux上安装Scala详细步骤

    scala在linux安装很简单,就是下载,解压,配置环境变量,source一下成功. 提君博客原创 >>提君博客原创 http://www.cnblogs.com/tijun/ < ...

  3. liunx 运维知识三部分

    一. 用户级用户组相关 二. 文件属性和链接知识及磁盘已满故障案例 三. 通配符 四. 特殊符号 五. 基础正则 六. 扩展正则 七. sed实践 八. awk实践

  4. python学习笔记(6)--条件分支语句

    if xxxx: coding if xxxx: coding else: coding if xxxx: coding elif xxx: coding …… else: coding 或者一种简洁 ...

  5. python设计模式第十七天【解释器模式】

    1.应用场景 (1)解释预先定义的文法 2.代码实现 #!/usr/bin/env python #!_*_ coding:UTF-8 _*_ from abc import ABCMeta, abs ...

  6. TP5系统变量输出

    1.超全局变量 模板中: {$Think.sever.server_name}              //全部小写,输出blog.cn 控制器: $_SERVER['SERVER_NAME']  ...

  7. ADO工具类

    using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data; ...

  8. 设置和安装 BizTalk Server 2016 的必备组件

    设置服务器,然后安装和配置软件必备组件. 加入本地管理员组       若要安装并配置 BizTalk Server,在本地计算机上使用管理员帐户登录到服务器. 向本地管理员组添加任何管理 BizTa ...

  9. codeforces545C

    Woodcutters CodeForces - 545C Little Susie listens to fairy tales before bed every day. Today's fair ...

  10. 关于Binder,作为应用开发者你需要知道的全部

    作者:rushjs https://www.jianshu.com/p/062a6e4f5cbe github 地址: https://github.com/rushgit/zhongwenjun.g ...