1106 Lowest Price in Supply Chain
题意:略
思路:寻找树的叶结点中深度最低的,记录最低深度minDepth和具有相同最低深度的结点个数cnt。
代码:
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;
;
vector<int> tree[maxn];
,cnt=;
void dfs(int v,int depth)
{
){
if(depth<minDepth){
cnt=;
minDepth=depth;
}else if(depth==minDepth){
cnt++;
}
}
for(auto u:tree[v])
dfs(u,depth+);
}
int main()
{
int n,k;
double price,r;
scanf("%d%lf%lf",&n,&price,&r);
;i<n;i++){
scanf("%d",&k);
int kid;
;j<k;j++){
scanf("%d",&kid);
tree[i].push_back(kid);
}
}
dfs(,);
r=(r+)/100.0;
printf("%.4f %d",price*pow(r,minDepth),cnt);
;
}
1106 Lowest Price in Supply Chain的更多相关文章
- [建树(非二叉树)] 1106. Lowest Price in Supply Chain (25)
1106. Lowest Price in Supply Chain (25) A supply chain is a network of retailers(零售商), distributors( ...
- PAT甲级——1106 Lowest Price in Supply Chain(BFS)
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90444872 1106 Lowest Price in Supp ...
- 1106. Lowest Price in Supply Chain (25)
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...
- PAT 甲级 1106 Lowest Price in Supply Chain
https://pintia.cn/problem-sets/994805342720868352/problems/994805362341822464 A supply chain is a ne ...
- PAT 1106 Lowest Price in Supply Chain
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...
- PAT Advanced 1106 Lowest Price in Supply Chain (25) [DFS,BFS,树的遍历]
题目 A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)– everyone in ...
- PAT (Advanced Level) 1106. Lowest Price in Supply Chain (25)
简单dfs #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...
- 1106 Lowest Price in Supply Chain (25 分)(树的遍历)
求叶子结点处能活得最低价格以及能提供最低价格的叶子结点的个数 #include<bits/stdc++.h> using namespace std; ; vector<int> ...
- PAT甲题题解-1106. Lowest Price in Supply Chain (25)-(dfs计算树的最小层数)
统计树的最小层数以及位于该层数上的叶子节点个数即可. 代码里建树我用了邻接链表的存储方式——链式前向星,不了解的可以参考,非常好用: http://www.cnblogs.com/chenxiwenr ...
随机推荐
- LeetCode OJ:Gray Code(格林码)
The gray code is a binary numeral system where two successive values differ in only one bit. Given a ...
- 今天开始写些随笔,就从Jplayer开始吧
今天才开始用Jplayer,可能有点落伍了,但是看到网上千篇一律的使用说明,开始决定把自己的使用心得分享一下,废话不多说,开始吧. Step1: 官网上有具体的搭建顺序,URL:http://www. ...
- SpringInAction--条件化的Bean
学习了profile bean之后,发现有的时候bean还是有根据环境来选择的余地的,那么假设我们希望某个bean只有当另外某个特定的bean也声明了之后才会创建.我们还可能要求只有某个特定的环境变量 ...
- core文件介绍
原文链接:http://team.eyou.com/?p=27 如有侵犯您的版权,请联系windeal12@qq.com linux下,产生core文件,和不产生core文件的条件: 当我们的程序崩溃 ...
- c# 多线程调用窗体上的控件 示例
private delegate void InvokeCallback(string msg); private void SetCountValue(string s) { if (this.fo ...
- java事务(一)
Java中事务处理的基本方法与原理,包含以下文章: (一)Java事务处理的基本问题 (二)失败的案例 (三)丑陋的案例 (四)成功的案例(自己实现一个线程安全的TransactionManager) ...
- linux c++ 多线程心得
好久没写多线程了,工作好几年也没怎么大规模的写过多线程,都是成形的架构里写业务逻辑.偶尔自己写了下,各种踩坑... 1.string 不是线程安全的 一个特例是std::string.在一些STL的实 ...
- 如何写一个LaTeX类文件,并设计你自己的简历
2017/8/29 20:26:03 原文地址 https://www.sharelatex.com/blog/2011/03/27/how-to-write-a-latex-class-file-a ...
- HDU3833 YY's new problem 卡时间第一题
Given a permutation P of 1 to N, YY wants to know whether there exists such three elements P[i 1], P ...
- swing自定义JDialog弹出框
第一次搞swing,自定义JDialog的例子较少,写下来备忘 ,对JDialog中的文本框进行了验证 package com.chauvet; import java.awt.Component; ...