#include<bits/stdc++.h>
using namespace std;
int fa;
int degree[100007];
vector<int>v[100007];
void dfs(int x){
    for(auto&it:v[x]){
        degree[it]=degree[x]+1;
        dfs(it);
    }
    return;
}
double qpow(double x,int y){
    double ans=1,tmp=x;
    while(y){
        if(y&1)
            ans*=tmp;
        tmp*=tmp;
        y>>=1;
    }
    return ans;
}
int main(){
    int n;
    double p,r;
    scanf("%d%lf%lf",&n,&p,&r);
    int root=0;
    for(int i=0;i<n;++i){
        scanf("%d",&fa);
        if(fa==-1)
            root=i;
        else
            v[fa].push_back(i);
    }
    dfs(root);
    int mx=0;
    for(int i=0;i<n;++i)
        mx=max(mx,degree[i]);
    int num=0;
    for(int i=0;i<n;++i)
        if(degree[i]==mx)
            num++;
    double ans=p*qpow(1.0+r/100,mx);
    printf("%.2f %d",ans,num);
    return 0;
}

Highest Price in Supply Chain (25)(DFS)(PAT甲级)的更多相关文章

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

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

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

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

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

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

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

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

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

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

  6. PAT Advanced 1106 Lowest Price in Supply Chain (25) [DFS,BFS,树的遍历]

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

  7. 1090. Highest Price in Supply Chain (25)

    时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A supply chain is a network of r ...

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

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

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

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

随机推荐

  1. python第五篇:Linux上将txt导入mysql

    昨天写小项目的时候遇到了一个需求:把txt文档的数据导入到mysql数据库中,开始本来想直接用Mysql Workbench导入TXT文件,但是最后发现不支持TXT导入,结果我吧嗒吧嗒的去把TXT转了 ...

  2. BZOJ 2243 [SDOI2011]染色:树剖【维护路径上颜色段】

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2243 题意: 给定一棵有n个节点的无根树和m个操作,操作有2类: 1.将节点a到节点b路径 ...

  3. define的用法与注意事项

    ------------------------------------------------- 在编程使用宏替换时,当字符串中不只一个符号时,加上括号表现出优先级, 如果是带参数的宏定义,则要给宏 ...

  4. 封装一个简单的Hibernate SessionFactory

    封装Hibernate框架中的session工厂   ,方便很多,免去了很多重复无用的代码 package com.maya.test; import org.hibernate.*; import ...

  5. python-字典和json

    Python的字典和JSON在表现形式上非常相似 #这是Python中的一个字典 dic = { 'str': 'this is a string', 'list': [1, 2, 'a', 'b'] ...

  6. BEC listen and translation exercise 38

    很高兴看到有这么多人想了解我们的体育设施.It's good to see that there are so many people wanting to find out about our sp ...

  7. CodeForces - 1C:Ancient Berland Circus (几何)

    Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things ...

  8. iPhone X机型适配

    1.启动页 启动App,发现App只能居中显示,不能上下充满. 问题产生的原因是:iPhone X是5.8英寸,比5.5英寸的屏幕还要大,没有合适的启动页可以加载,所以只能使用以前5.5英寸的启动页, ...

  9. 如何在开启了log-bin的MySQL Server中创建FUNCTION

    在MySQL主从复制机器的master的数据库中创建function,报出如下错误: Error Code: 1418. This function has none of DETERMINISTIC ...

  10. 拓扑排序 POJ 1094 Sorting It All Out

    题意:给定N个字和M行他们之间的关系,要求输出他们的拓扑排序.此题采用边输入边检测的方式,如果发现环,就结束并输出当前行号:如果读取到当前行时,可以确定拓扑序列就输出,不管后面的输入(可能包含环路): ...