题意:略

思路:寻找树的叶结点中深度最低的,记录最低深度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的更多相关文章

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

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

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

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

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

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

  4. PAT 甲级 1106 Lowest Price in Supply Chain

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

  5. PAT 1106 Lowest Price in Supply Chain

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

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

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

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

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

  8. 1106 Lowest Price in Supply Chain (25 分)(树的遍历)

    求叶子结点处能活得最低价格以及能提供最低价格的叶子结点的个数 #include<bits/stdc++.h> using namespace std; ; vector<int> ...

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

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

随机推荐

  1. 【前端工具】 git windows下搭建全过程

    1. Git,Windows下的Git,地址:http://msysgit.googlecode.com/files/Git-1.7.9-preview20120201.exe(方便下载) 2 .SS ...

  2. 2017北京赛区H题

    题目链接 题意:在n*m的矩阵中选择变换或者不变换一个数变成p,使得最大子矩阵和最小 1<=n,m<=150, -1000<=p<=1000; 题解: 他人题解链接 涉及到知识 ...

  3. LINUX系统下的磁盘共享

      在一台主机上实现磁盘的共享:在另一台主机中进行使用.具体操作如下: 1)在服务器端(server) 1.安装软件和磁盘的划分 yum install targetcli.noarch -y     ...

  4. Linux网络编程IPv4和IPv6的inet_addr、inet_aton、inet_pton等函数小结

    知识背景: 210.25.132.181属于IP地址的ASCII表示法,也就是字符串形式.英语叫做IPv4 numbers-and-dots notation. 如果把210.25.132.181转换 ...

  5. ubuntu16安装git

    执行一条命令就可以: sudo apt-get install git

  6. CUDA Samples: Streams' usage

    以下CUDA sample是分别用C++和CUDA实现的流的使用code,并对其中使用到的CUDA函数进行了解说,code参考了<GPU高性能编程CUDA实战>一书的第十章,各个文件内容如 ...

  7. java.lang.IllegalArgumentException: Invalid character found in method name

    1.错误描述 信息: Error parsing HTTP request header Note: further occurrences of HTTP header parsing errors ...

  8. Ubuntu16.04 --> 14.04

    从16到14 自认为14是比较稳定的.从安装依赖上说. 14安装应用 更多参见[请直接拉到"华丽丽的分割线"下面] Java9 注意,添加源的时候先把lantern打开!!! 添加 ...

  9. java 中的锁 -- 偏向锁、轻量级锁、自旋锁、重量级锁

    之前做过一个测试,详情见这篇文章<多线程 +1操作的几种实现方式,及效率对比>,当时对这个测试结果很疑惑,反复执行过多次,发现结果是一样的: 1. 单线程下synchronized效率最高 ...

  10. 【Codeforces】Round #488 (Div. 2) 总结

    [Codeforces]Round #488 (Div. 2) 总结 比较僵硬的一场,还是手速不够,但是作为正式成为竞赛生的第一场比赛还是比较圆满的,起码没有FST,A掉ABCD,总排82,怒涨rat ...