#include <iostream>
#include <vector>
#include <cmath>
using namespace std;int n, maxnum, maxdepth = 0, root = 0;
double p, r;
vector<int> v[100001];//存放树void dfs(int index, int depth){if (v[index].size() == 0) {if(maxdepth == depth) maxnum++;if (maxdepth < depth) {maxdepth = depth;maxnum = 1;}return;}for (int i = 0; i < v[index].size(); i++) {//递归访问结点index的子结点dfs(v[index][i], depth + 1);}
}int main(){cin >> n >> p >> r;for (int i = 0; i < n; i++) {int t;cin >> t;if(t == -1) root = i;else v[t].push_back(i);//i是t的子结点}dfs(root, 0);printf("%.2lf %d\n", p * pow(1 + r/100, maxdepth), maxnum);return 0;
}

1090. Highest Price in Supply Chain (25) dfs相关推荐

  1. PAT甲级 -- 1090 Highest Price in Supply Chain (25 分)

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

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

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

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

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

  4. 1090 Highest Price in Supply Chain (25)

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

  5. 1090. Highest Price in Supply Chain (25)-PAT甲级真题

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

  6. PAT:1090. Highest Price in Supply Chain (25) AC

    #include<stdio.h> #include<vector> using namespace std; const int MAX=100010; int DEPest ...

  7. 1090 Highest Price in Supply Chain (25 分)【难度: 一般 / 知识点: 树的遍历】

    https://pintia.cn/problem-sets/994805342720868352/problems/994805376476626944 就是找深度最深的叶节点的深度,和最深的结点个 ...

  8. 1090 Highest Price in Supply Chain(甲级)

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

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

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

最新文章

  1. linux-命令替换-通配符-重定向-管道
  2. 有关Spring注解@xxx的零碎知识
  3. iOS中的应用启动原理
  4. 如何在面试中通过工厂模式来给自己加分?逆袭面经分享
  5. 你会通过Docker部署war包吗
  6. C++杂记之this指针
  7. c# 获取excel单元格公式结果_EXCEL公式解析:单元格中数字去重排序思路及公式详解...
  8. TypeScript:变量和数据类型
  9. Android开发Java版 —— 基础知识
  10. dell网卡linux驱动,[求助]Linux下dell的无线网卡驱动的安装
  11. 3dmax2014 uv用法_3ds max uv展开教程
  12. WRF主程序与WPS的编译与安装
  13. python苹果支付(服务端)自动订阅版
  14. linux批量删除文件或者文件夹
  15. 搭建直播平台,你需要先知道这些
  16. 通频带、阻值、放大倍数之间的关系(Multisim仿真所得)
  17. Android Gesture 手势识别使用实例
  18. 气瓶安全云充装V1.0.201604
  19. L*MM 文件管理器小结
  20. python对txt分段处理_使用python对txt格式的小说进行处理

热门文章

  1. java 打印hashmap值_HashMap中输出key-value值得方法
  2. Java基础拾遗:线程相关问题
  3. PHP CURL模拟POST提交XML数据
  4. springboot整合通用mapper操作数据库
  5. SpringBoot启动全流程源码解析(超详细版)
  6. Java高并发编程详解系列-Guarded Suspension设计模式
  7. 浅谈SDN中的OverLay与UnderLay技术
  8. jquery.form.js java_教javascript函数和jquery函数的使用$(form).submit(function()
  9. 实战:MongoDB 分片集群Shard Cluster 搭建(1台路由节点,3台配置节点,9台分片节点)
  10. 标题:DKhadoop大数据处理平台监控数据介绍