时间限制
200 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

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. 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 highest price we 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 they are numbered from 0 to N-1); P, the price given by the root supplier; and r, the percentage rate of price increment for each distributor or retailer. Then the next line contains N numbers, each number Si is the index of the supplier for the i-th member. Sroot for the root supplier is defined to be -1. All the numbers in a line are separated by a space.

Output Specification:

For each test case, print in one line the highest price we can expect from some retailers, accurate up to 2 decimal places, and the number of retailers that sell at the highest price. There must be one space between the two numbers. It is guaranteed that the price will not exceed 1010.

Sample Input:

9 1.80 1.00
1 5 4 4 -1 4 5 3 6

Sample Output:

1.85 2
 #include<stdio.h>
#include<vector>
#include<math.h>
using namespace std; struct Node
{
int level;
vector<int> child;
}; Node Tree[];
bool visit[]; int MAX; vector<int> Maxque; void DFS(int root,int level,double price,double rate)
{
visit[root] = true;
if(Tree[root].child.empty())
{
Maxque.push_back(level);
if(level > MAX ) MAX = level;
}
else
{
for(int i = ;i < Tree[root].child.size();i++)
{
if(visit[Tree[root].child[i]] == false)
DFS(Tree[root].child[i],level+,price,rate);
}
}
} int main()
{
int ID,num,i,root;
double price,rate;
scanf("%d%lf%lf",&num,&price,&rate);
for( i = ; i < num ;i++)
{
Tree[i].child.clear();
visit[i]= false;
}
for(i = ;i < num ;i ++)
{
scanf("%d",&ID);
if(ID != -)
Tree[ID].child.push_back(i);
else root = i;
} int level = ;
MAX = -;
DFS(root,level,price,rate); int count = ;
for(i = ;i< Maxque.size() ;i++)
if( Maxque[i] == MAX ) ++count;
printf("%0.2lf %d\n",price*pow( (+rate)/,MAX),count); return ;
}

1090. Highest Price in Supply Chain (25)的更多相关文章

  1. [建树(非二叉树)] 1090. Highest Price in Supply Chain (25)

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

  2. 1090. Highest Price in Supply Chain (25) -计层的BFS改进

    题目如下: A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyon ...

  3. 1090 Highest Price in Supply Chain (25)(25 分)

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

  4. PAT Advanced 1090 Highest Price in Supply Chain (25) [树的遍历]

    题目 A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)–everyone inv ...

  5. PAT (Advanced Level) 1090. Highest Price in Supply Chain (25)

    简单dfs. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...

  6. 1090. Highest Price in Supply Chain (25)-dfs求层数

    给出一棵树,在树根出货物的价格为p,然后每往下一层,价格增加r%,求所有叶子节点中的最高价格,以及该层叶子结点个数. #include <iostream> #include <cs ...

  7. 【PAT甲级】1090 Highest Price in Supply Chain (25 分)

    题意: 输入一个正整数N(<=1e5),和两个小数r和f,表示树的结点总数和商品的原价以及每向下一层价格升高的幅度.下一行输入N个结点的父结点,-1表示为根节点.输出最深的叶子结点处购买商品的价 ...

  8. pat1090. Highest Price in Supply Chain (25)

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

  9. PAT 1090 Highest Price in Supply Chain[较简单]

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

随机推荐

  1. MySQL(19):SQL语句(MySQL)大全

    SQL语句大全一.创建和删除数据库 1.创建用户 //创建用户且置密码,在MySQL中行,但在Oracle中行  ----必须在超级管理员身份下操作 create user hncu identifi ...

  2. PHP读书笔记(6)- 数组

    数组定义 数组就是一个键值对组成的语言结构,键类似于酒店的房间号,值类似于酒店房间里存储的东西.PHP 中的数组实际上是一个有序映射.映射是一种把 values 关联到 keys 的类型. 定义数组 ...

  3. [未完成]关于POI的使用

    关于POI的使用关于POI的使用关于POI的使用关于POI的使用

  4. const 指针与指向const的指针

    最近在复习C++,指针这块真的是重难点,很久了也没有去理会,今晚好好总结一下const指针,好久没有写过博客了,记录一下~ const指针的定义: const指针是指针变量的值一经初始化,就不可以改变 ...

  5. 在CentOS6.4中安装配置LAMP环境的详细步骤

    本文详细介绍了CentOS6.4系统中安装LAMP服务并对其进行配置的过程,即安装Apache+PHP+Mysql,参照了网上大神的设置,其他Linux发行系统可以参考~ 在本文中部分命令操作需要ro ...

  6. Slickflow.NET 开源工作流引擎基础介绍(一) -- 引擎基本服务接口API介绍

    1. 工作流术语图示                                              图1 流程图形的BPMN图形元素表示 1) 流程模型定义说明流程(Process):是企 ...

  7. C#算法基础之冒泡排序

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

  8. 解析LRC歌词文件readlrc

    package com.jikexueyuan.readlrc.main; import com.jikexueyuan.readlrc.utils.Utils; import java.io.Fil ...

  9. batch 数字进制的问题

    when set viable to number type in cmdexample: set /a num=0833echo %num% display: Invalid number.  Nu ...

  10. 基于DIV+ul+li实现的表格(多示例)

    一个无序列表biaoge,前四个列表项我们赋予了类biaotou.因为这四个项是表格头部,应该与表格数据有所区别.所以单独赋予了类,可以方便控制.下面我们开始CSS代码的编写:由 www.169it. ...