题意:
输入一个正整数N(<=1e5),两个小数P和R,分别表示树的结点个数和商品原价以及每下探一层会涨幅的百分比。输出叶子结点深度最小的商品价格和深度最小的叶子结点个数。

trick:

测试点1只有根节点一个点,输出P和1。

AAAAAccepted code:

 #define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
vector<int>v[];
int store[];
void dfs(int x,int y){
if(v[x].size()==)
store[x]=y;
for(auto it:v[x]){
dfs(it,y+);
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
double p,r;
cin>>p>>r;
for(int i=;i<n;++i){
int x;
cin>>x;
for(int j=;j<=x;++j){
int y;
cin>>y;
v[i].push_back(y);
}
}
dfs(,);
int mn=1e9;
for(int i=;i<n;++i)
if(store[i])
mn=min(mn,store[i]);
int num=;
if(mn==1e9)
mn=;
for(int i=;i<n;++i)
if(store[i]==mn)
++num;
double ans=pow(1.0+r/,mn);
ans*=p;
printf("%.4lf %d",ans,num);
return ;
}

【PAT甲级】1106 Lowest Price in Supply Chain (25分)的更多相关文章

  1. PAT甲级——1106 Lowest Price in Supply Chain(BFS)

    本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90444872 1106 Lowest Price in Supp ...

  2. PAT 甲级 1106 Lowest Price in Supply Chain

    https://pintia.cn/problem-sets/994805342720868352/problems/994805362341822464 A supply chain is a ne ...

  3. PAT Advanced 1106 Lowest Price in Supply Chain (25) [DFS,BFS,树的遍历]

    题目 A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)– everyone in ...

  4. [建树(非二叉树)] 1106. Lowest Price in Supply Chain (25)

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

  5. PAT 甲级 1079 Total Sales of Supply Chain (25 分)(简单,不建树,bfs即可)

    1079 Total Sales of Supply Chain (25 分)   A supply chain is a network of retailers(零售商), distributor ...

  6. PAT甲级——A1106 Lowest Price in Supply Chain

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

  7. 1106. Lowest Price in Supply Chain (25)

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

  8. PAT (Advanced Level) 1106. Lowest Price in Supply Chain (25)

    简单dfs #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...

  9. PAT甲题题解-1106. Lowest Price in Supply Chain (25)-(dfs计算树的最小层数)

    统计树的最小层数以及位于该层数上的叶子节点个数即可. 代码里建树我用了邻接链表的存储方式——链式前向星,不了解的可以参考,非常好用: http://www.cnblogs.com/chenxiwenr ...

随机推荐

  1. 2020年,最新NGINX的ngx_http_geoip2模块以精准禁止特定国家或者地区IP访问

    1.0 geoip2核心识别库 安装geoip2 lib步骤: cd /usr/local/src .tar.gz wget https://github.com/maxmind/libmaxmind ...

  2. python3练习100题——032

    链接:http://www.runoob.com/python/python-exercise-example32.html 题目:按相反的顺序输出列表的值. 我的代码: for i in li[:: ...

  3. FOJ-2013 A Short Problem (前缀和)

    Problem Description The description of this problem is very short. Now give you a string(length N), ...

  4. 《深入理解Java虚拟机》读书笔记六

    第七章 虚拟机类加载机制 1.类加载的时机 虚拟机的类加载机制: 虚拟机把描述类的数据从class文件中加载到内存,并对数据进行校验.转换解析和初始化,最终形成了可以被虚拟机直接使用的Java类型,这 ...

  5. soundtouch change rate matlab implementation

    soundtouch implement of changing rate in a way same with resample(SRC). When rate < 1, it need in ...

  6. linux 部署 .net 程序

    1.使用jexus https://www.jexus.org/ 2.“loopback”错误

  7. C#中向ListView控件中添加一行数据

    C#中向ListView控件中添加一行数据: ,先声明一个ListViewItem: ListViewItem item = new ListViewItem(); ,添加第一列数据: item.Te ...

  8. leetcode 1214 Two Sum BSTs

    function rob(a, b, target) { var hash = {} var stack = [a] while (queue.length) { var node = stack.p ...

  9. JAVASCRIPT实现的WEB页面跳转以及页面间传值方法

    在WEB页面中,我们实现页面跳转的方法通常是用LINK,BUTTON LINK ,IMG LINK等等,由用户点击某处,然后直接由浏览器帮我们跳转. 但有时候,需要当某事件触发时,我们先做一些操作,然 ...

  10. DBContext基础查询

    https://www.cnblogs.com/gosky/p/5752001.html 遍历所有实体 //遍历所有学生 DBSet using (var db = new Entities()) { ...