题意:
输入一个正整数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. selenium统计网页加载时间

    参考网址: https://blog.csdn.net/thlzjfefe/article/details/99712974 https://blog.csdn.net/weixin_43664254 ...

  2. python vs java Threadpool

    python 实现threadpool线程池管理: from concurrent.futures import ThreadPoolExecutor as te from concurrent.fu ...

  3. 迭代器iterator遍历map集合

    结果:

  4. python之路模块补充

    =======================================json序列化========================================= ============ ...

  5. K3/Cloud点按钮打开单据,列表,动态表单,简单账表和直接Sql报表示例

    BOS IDE中配置了个界面,拖了动态表单界面,加了5个测试按钮. 点击“打开单据”维护界面, 会跳转到一个新的主界面页签,[物料]新增 点击“打开列表”,会弹出[物料]列表界面 点击“打开动态表单” ...

  6. K3老单序时簿开发示例

    K3需要对老单进行二次开发,老单的二次开发比较麻烦,这里整理一下老单序时簿上添加按钮的二次开发示例. --以下SQL脚本--获取 MENU IDselect FID,FmenuID,FName fro ...

  7. linq和匿名方法、委托、匿名委托、lambda

    委托相当于JavaScript中的闭包,c++中的函数指针. c#为了引进这个函数指针,将其进行包装成“委托”,同时将非托管的变成托管的. 1.最初的委托该怎么用 弊端:写的代码量过多,还要写一个显示 ...

  8. C++——简单程序设计

    1.一个简单的程序 #include <iostream> //iostream是头文件,用来说明要使用的对象的相关信息. using namespace std; //使用命名空间,解决 ...

  9. 显示当前目录命令 - pwd

    1) 命令名称:pwd 2) 英文原意:print working directory 3) 命令所在路径:/bin/pwd 4) 执行权限:所有用户 5) 功能描述:显示当前目录 6) 语法: pw ...

  10. python3 yield实现假的多并发

    import time def fun1(): while True: print("fun1") time.sleep(0.1) yield def fun2(): while ...