#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. 分享知识-快乐自己:Liunx 安装 Zookeeper

    Zookeeper可以安装在windows中也可以安装在linux中! 但是我们的服务器基本都是在linux之上 安装我们的 zookeeper 注册中心! 安装成功之后  修改 nat 模式对应的端 ...

  2. 再次理解WCF以及其通信(附加一個編程小經驗)

    一.概述 Windows Communication Foundation(WCF)是由微软发展的一组数据通信的应用程序开发接口,可以翻译为Windows通讯接口,它是.NET框架的一部分.由 .NE ...

  3. 大数据日志分析产品——SaaS Cloud, e.g. Papertrail, Loggly, Sumo Logic;Open Source Frameworks, e.g. ELK stack, Graylog;Enterprise Products, e.g. TIBCO LogLogic, IBM QRadar, Splunk

    Learn how you can maximize big data in the cloud with Apache Hadoop. Download this eBook now. Brough ...

  4. 一种解决 MacBook 里的 App Store 无法登录的问题

    刚刚买回来的 2018 款带有 touchbar 的 MacBook Pro 15 inc 在用 App Store 安装 app 时一直无法登录成功(网络链接都是好的),导致软件都无法更新,折腾了挺 ...

  5. 关于C++多态的理解

    多态,即多种形态.对于具有继承关系的一类对象,子类表现出了父类的某些特性,但是表现的不一样,这就是多态的现实体现.例如动物可以发声,但是狗是旺旺,狗是动物的一种,但是表现了不同的叫的特点,这就是多态. ...

  6. I.MX6 Python3 OpenCV

    /************************************************************************* * I.MX6 Python3 OpenCV * ...

  7. C++之this指针与另一种“多态”

    一.引入 定义一个类的对象,首先系统已经给这个对象分配了空间,然后会调用构造函数(说明:假设存在构造函数--2010.9.5修正). 一个类有多个对象,当程序中调用对象的某个函数时,有可能要访问到这个 ...

  8. ACM学习历程—HDU5478 Can you find it(数论)(2015上海网赛11题)

    Problem Description Given a prime number C(1≤C≤2×105), and three integers k1, b1, k2 (1≤k1,k2,b1≤109 ...

  9. bzoj 4530 大融合 —— LCT维护子树信息

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4530 用LCT维护子树 size,就是实边和虚边分开维护: 看博客:https://blog ...

  10. css中的特殊居中

    大图居中: 先看一下普通的居中: 代码为: <!DOCTYPE html> <html lang="en"> <head> <meta c ...