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

trick:

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

AAAAAccepted code:

  1. #define HAVE_STRUCT_TIMESPEC
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. vector<int>v[];
  5. int store[];
  6. void dfs(int x,int y){
  7. if(v[x].size()==)
  8. store[x]=y;
  9. for(auto it:v[x]){
  10. dfs(it,y+);
  11. }
  12. }
  13. int main(){
  14. ios::sync_with_stdio(false);
  15. cin.tie(NULL);
  16. cout.tie(NULL);
  17. int n;
  18. cin>>n;
  19. double p,r;
  20. cin>>p>>r;
  21. for(int i=;i<n;++i){
  22. int x;
  23. cin>>x;
  24. for(int j=;j<=x;++j){
  25. int y;
  26. cin>>y;
  27. v[i].push_back(y);
  28. }
  29. }
  30. dfs(,);
  31. int mn=1e9;
  32. for(int i=;i<n;++i)
  33. if(store[i])
  34. mn=min(mn,store[i]);
  35. int num=;
  36. if(mn==1e9)
  37. mn=;
  38. for(int i=;i<n;++i)
  39. if(store[i]==mn)
  40. ++num;
  41. double ans=pow(1.0+r/,mn);
  42. ans*=p;
  43. printf("%.4lf %d",ans,num);
  44. return ;
  45. }

【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. AntDesign(React)学习-5 路由及使用Layout布局

    前言:学习目标实现点击登录按钮,直接进入后台布局页面,类似下面antd官网文档展示效果 ant.design访问 https://ant-design.gitee.io/components/menu ...

  2. zabbix4.4.2安装部署

    1.下载阿里的源,执行 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 2 ...

  3. javacv FFmpeg 视频压缩

    package com.nmcc.demo.utils; import lombok.extern.slf4j.Slf4j; import org.bytedeco.javacpp.avcodec; ...

  4. glog入门demo

    glog 一. 下载与安装 git clone https://github.com/google/glog.git cd glog ./autogen.sh ./configure make mak ...

  5. repeater列表中直接修改状态

    <asp:Repeater ID="RepeaterArticleList" runat="server" onitemdatabound="R ...

  6. C#连接数据库时Appsettings 与connectionStrings的区别

    C#连接数据库时Appsettings 与connectionStrings的区别 转载lscyo 最后发布于2018-08-08 18:38:04 阅读数 3366  收藏 展开 一..Appset ...

  7. 使用pip install mysqlclient命令安装mysqlclient失败?(基于Python)

    我们使用Django.flask等来操作MySQL,实际上底层还是通过Python来操作的.因此我们想要用Django来操作MySQL,首先还是需要安装一个驱动程序.在Python3中,驱动程序有多种 ...

  8. 保存数据到文件的模块(json,pickle,shelve,configparser,xml)_python

    一.各模块的主要功能区别 json模块:将数据对象从内存中完成序列化存储,但是不能对函数和类进行序列化,写入的格式是明文.  (与其他大多语言交互的类型) pickle模块:将数据对象从内存中完成序列 ...

  9. Echat 地图样式格式

    1.白色 mapStyle: { styleJson: [{ 'featureType': 'water', 'elementType': 'all', 'stylers': { 'color': ' ...

  10. 终极教程【zhong】

    just for a better future! 资源教程               aiim                   综合类 前端知识体系 前端知识结构 Web前端开发大系概览 We ...