题意:

输入一个正整数N(<=1e5),表示共有N个结点,接着输入两个浮点数分别表示商品的进货价和每经过一层会增加的价格百分比。接着输入N行每行包括一个非负整数X,如果X为0则表明该结点为叶子结点接着输入一个整数表示该零售商进货的数量,X不为零则接着输入X个正整数表示它的下级经销商是哪些结点。输出所有零售商进货的总价。(结点从0~N-1,0为根节点即供应商)

AAAAAccepted code:

 #include<bits/stdc++.h>
using namespace std;
int a[],lv[],ans[];
vector<int>v[];
void dfs(int x){
for(int it=;it<v[x].size();++it){
lv[v[x][it]]=lv[x]+;
dfs(v[x][it]);
}
}
int main(){
int n;
cin>>n;
double p,r;
cin>>p>>r;
int cnt=;
for(int i=;i<n;++i){
int x,num;
cin>>x;
if(!x){
cin>>num;
a[i]=num;
ans[++cnt]=i;
}
for(int j=;j<=x;++j){
cin>>num;
v[i].push_back(num);
}
}
dfs();
double sum=;
for(int i=;i<=cnt;++i){
double tamp=1.0*a[ans[i]]*p*pow(1.0+0.01*r,lv[ans[i]]);
sum+=tamp;
}
printf("%.1lf",sum);
return ;
}

【PAT甲级】1079 Total Sales of Supply Chain (25 分)的更多相关文章

  1. 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 ...

  2. PAT 甲级 1079 Total Sales of Supply Chain

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

  3. PAT Advanced 1079 Total Sales of Supply Chain (25) [DFS,BFS,树的遍历]

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

  4. 1079. Total Sales of Supply Chain (25)【树+搜索】——PAT (Advanced Level) Practise

    题目信息 1079. Total Sales of Supply Chain (25) 时间限制250 ms 内存限制65536 kB 代码长度限制16000 B A supply chain is ...

  5. 1079. Total Sales of Supply Chain (25)-求数的层次和叶子节点

    和下面是同类型的题目,只不过问的不一样罢了: 1090. Highest Price in Supply Chain (25)-dfs求层数 1106. Lowest Price in Supply ...

  6. PAT甲级——A1079 Total Sales of Supply Chain

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

  7. 1079. Total Sales of Supply Chain (25)

    时间限制 250 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A supply chain is a network of r ...

  8. 1079. Total Sales of Supply Chain (25) -记录层的BFS改进

    题目如下: A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyon ...

  9. PAT (Advanced Level) 1079. Total Sales of Supply Chain (25)

    树的遍历. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...

随机推荐

  1. 爬虫实战 豆瓣音乐top250 xpath

    刷知乎时刷到一篇爬取豆瓣音乐top250的,然后看了看,感觉自己的爬虫又更上一层楼了哈啊哈哈,尤其是发现xpath这么好用的东西. 不过也有一个感慨,就是有很多种方式都可以获得想要的数据,对于入门的新 ...

  2. 直接打印类,调用toString()方法

    直接打印类,调用的是继承的Object类的toString()方法,Object类的toString()方法是这样实现的:getClass().getName() + "@" + ...

  3. 解决linux 中文乱码

    解决办法是在文件/etc/profile末尾添加一行 echo 'export LC_ALL="en_US.UTF-8"' >> /etc/profile source ...

  4. biquad filter实现

    原始频谱: LPF: HPF: 代码: #include<stdio.h> #include<stdlib.h> #include<errno.h> #includ ...

  5. Tomcat配置过程

    Tomcat的配置其实还是挺简单的,下面是在Myeclipse中配置 1.首先要在Tomcat官网下载,网址:http://tomcat.apache.org/,然后左侧会有Download,选择你要 ...

  6. jsp页面直接读取mysql数据库数据显示

    jsp页面直接读取mysql数据库数据显示: <%@page import="java.sql.ResultSet"%> <%@page import=" ...

  7. 2019 ICPC南京网络赛 F题 Greedy Sequence(贪心+递推)

    计蒜客题目链接:https://nanti.jisuanke.com/t/41303 题目:给你一个序列a,你可以从其中选取元素,构建n个串,每个串的长度为n,构造的si串要满足以下条件, 1. si ...

  8. Codeforces A. Serval and Bus

    inputstandard inputoutputstandard outputIt is raining heavily. But this is the first day for Serval, ...

  9. iview渲染函数

    <Table border :columns="discountColumns" :data="discountData.rows"></Ta ...

  10. 后台怎么区分接口要写在哪个service类中呢(根据service服务区分)

    1,明确页面要实现什么功能,则页面对应的controller要写对应的controller方法 2,这个功能最终要由谁实现完成,在对应的service中药实现这个功能 3,这个接口的实现就写在最终完成 ...