1090 Highest Price in Supply Chain (25 分)【难度: 一般 / 知识点: 树的遍历】
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 分)【难度: 一般 / 知识点: 树的遍历】相关推荐
- PAT甲级 -- 1090 Highest Price in Supply Chain (25 分)
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...
- 1090 Highest Price in Supply Chain (25)(25 分)
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...
- 1090. Highest Price in Supply Chain (25)
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...
- 1090 Highest Price in Supply Chain (25)
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...
- 1090. Highest Price in Supply Chain (25)-PAT甲级真题
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...
- PAT:1090. Highest Price in Supply Chain (25) AC
#include<stdio.h> #include<vector> using namespace std; const int MAX=100010; int DEPest ...
- 1090. Highest Price in Supply Chain (25) dfs
#include <iostream> #include <vector> #include <cmath> using namespace std;int n, ...
- 1090 Highest Price in Supply Chain(甲级)
1090 Highest Price in Supply Chain (25分) A supply chain is a network of retailers(零售商), distributors ...
- 1090 Highest Price in Supply Chain (25 分)
1090 Highest Price in Supply Chain (25 分) A supply chain is a network of retailers(零售商), distributor ...
最新文章
- 知乎热议:科研界是如何保护自己的成果免于剽窃的?
- 特约专栏丨孙茂松教授——自然语言处理一瞥:知往鉴今瞻未来
- Java-POI操作excel清除单元格分行字符
- 第一次团队作业——团队展示
- @ExceptionHandler
- 嵌入式成长轨迹23 【Linux应用编程强化】【Linux下的C编程 下】【Linux GUI编程】...
- 24组合模式(Composite Pattern)
- ubuntu 18 Cannot find installed version of python-django or python3-django.
- Centos 监控进程,并自动重启
- 为虚幻引擎4设置Visual Studio
- python中字符串(二)-访问值、更新、转义、运算
- Ice简介+Qt代码示例
- Midnight Commander强大的命令行文件管理器
- Oracle 11g及PLSQL可视化界面的安装与使用(内附软件)
- php 处理raw数据,PHP用HTTP_RAW_POST_DATA来接收post过来的数据
- CFPS数据处理:少儿代答库与成人库匹配
- “你爱我,我爱你,蜜雪冰城甜蜜蜜“秋天的第一杯奶茶!Python安排!!
- 计算机显示屏知识,计算机配置知识之显示屏
- Mybatis层次结构图
- Springboot下RedisTemplate的两种序列化方式