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

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
vector<int>ve[N];
int n,deep,cnt;
double p,r;
void dfs(int u,int fa,int step)
{if(ve[u].size()==0) {if(deep==step) cnt++;else if(deep<step) deep=step,cnt=1;return;}for(int i=0;i<ve[u].size();i++){if(ve[u][i]==fa) continue;dfs(ve[u][i],u,step+1);}
}
int main(void)
{cin>>n>>p>>r;r/=100;for(int i=1;i<=n;i++){int x; cin>>x;x++;//让其从下标[0-n]ve[x].push_back(i);}dfs(0,-1,0);printf("%.2lf ",p*pow(1+r,deep-1));cout<<cnt<<endl;return 0;
}

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

  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) dfs

    #include <iostream> #include <vector> #include <cmath> using namespace std;int n, ...

  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. 知乎热议:科研界是如何保护自己的成果免于剽窃的?
  2. 特约专栏丨孙茂松教授——自然语言处理一瞥:知往鉴今瞻未来
  3. Java-POI操作excel清除单元格分行字符
  4. 第一次团队作业——团队展示
  5. @ExceptionHandler
  6. 嵌入式成长轨迹23 【Linux应用编程强化】【Linux下的C编程 下】【Linux GUI编程】...
  7. 24组合模式(Composite Pattern)
  8. ubuntu 18 Cannot find installed version of python-django or python3-django.
  9. Centos 监控进程,并自动重启
  10. 为虚幻引擎4设置Visual Studio
  11. python中字符串(二)-访问值、更新、转义、运算
  12. Ice简介+Qt代码示例
  13. Midnight Commander强大的命令行文件管理器
  14. Oracle 11g及PLSQL可视化界面的安装与使用(内附软件)
  15. php 处理raw数据,PHP用HTTP_RAW_POST_DATA来接收post过来的数据
  16. CFPS数据处理:少儿代答库与成人库匹配
  17. “你爱我,我爱你,蜜雪冰城甜蜜蜜“秋天的第一杯奶茶!Python安排!!
  18. 计算机显示屏知识,计算机配置知识之显示屏
  19. Mybatis层次结构图
  20. Springboot下RedisTemplate的两种序列化方式

热门文章

  1. select 实现server I/O多路复用通信
  2. 带有权重的服务器SLB的实现
  3. “北航Clubs” Beta版本开发目标
  4. 浅谈wcscpy_s之用法
  5. STM32F103V IWDG 独立看门狗操作
  6. Linux系统时间函数
  7. mysql从入门到转行图片_数据小白转行之路-MYSQL(二)
  8. stdthread(6)并发mutex
  9. 设计模式总结 (4)结构型模式
  10. 《研磨设计模式》chap12 观察者模式observer(1)模式简介