1079. Total Sales of Supply Chain (25)
来源:互联网 发布:休闲食品网络市场调查 编辑:程序博客网 时间:2024/06/12 05:29
1079. Total Sales of Supply Chain (25)
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.
Starting from one root supplier, everyone on the chain buys products from one's supplier in a price P and sell or distribute them in a price that is r% higher than P. Only the retailers will face the customers. It is assumed that each member in the supply chain has exactly one supplier except the root supplier, and there is no supply cycle.
Now given a supply chain, you are supposed to tell the total sales from all the retailers.
Input Specification:
Each input file contains one test case. For each case, the first line contains three positive numbers: N (<=105), the total number of the members in the supply chain (and hence their ID's are numbered from 0 to N-1, and the root supplier's ID is 0); P, the unit price given by the root supplier; and r, the percentage rate of price increment for each distributor or retailer. Then N lines follow, each describes a distributor or retailer in the following format:
Ki ID[1] ID[2] ... ID[Ki]
where in the i-th line, Ki is the total number of distributors or retailers who receive products from supplier i, and is then followed by the ID's of these distributors or retailers. Kj being 0 means that the j-th member is a retailer, then instead the total amount of the product will be given after Kj. All the numbers in a line are separated by a space.
Output Specification:
For each test case, print in one line the total sales we can expect from all the retailers, accurate up to 1 decimal place. It is guaranteed that the number will not exceed 1010.
Sample Input:10 1.80 1.003 2 3 51 91 41 70 72 6 11 80 90 40 3Sample Output:
42.4
#include<stdio.h>#include<stdlib.h>#include<math.h>#include<vector>using namespace std;struct Node{int data;vector<int> child;}List[100];int p;double n,r,ans=0;void DFS(int index,int depth){if(List[index].child.size()==0){ans+=List[index].data*pow(r+1,depth);return;}for(int i=0;i<List[index].child.size();i++){DFS(List[index].child[i],depth+1);}}int main(){int k,child,i;scanf("%d%lf%lf",&n,&p,&r);r=r/100;for(i=0;i<n;i++){scanf("%d",&k);if(k==0){ scanf("%lf",&List[i].data);}else{for(int j=0;j<k;j++){scanf("%d",&child);List[i].child.push_back(child);}}}DFS(0,0);printf("%lf",p*ans);system("pause");return 0;}
- 1079. Total Sales of Supply Chain (25)
- 1079. Total Sales of Supply Chain (25)
- 1079. Total Sales of Supply Chain (25)
- 1079. Total Sales of Supply Chain (25)
- 1079. Total Sales of Supply Chain (25)
- 1079. Total Sales of Supply Chain (25)
- 1079. Total Sales of Supply Chain (25)
- 1079. Total Sales of Supply Chain (25)
- 1079. Total Sales of Supply Chain (25)
- 1079. Total Sales of Supply Chain (25)
- 1079. Total Sales of Supply Chain (25)
- 1079. Total Sales of Supply Chain (25)
- 1079. Total Sales of Supply Chain (25)
- 1079. Total Sales of Supply Chain (25)
- 1079. Total Sales of Supply Chain (25)
- 1079. Total Sales of Supply Chain (25)
- 1079. Total Sales of Supply Chain (25)
- 1079. Total Sales of Supply Chain (25)
- idea build 无war包
- 内部类
- angularjs select 赋值 ng-options配置方式
- iOS 开发简单, 工资高。 用户群体消费水平高。Android 开发难很多,工资较低。
- 自定义SeekBar实现标尺指示范围的功能(含自定义shape等资源)
- 1079. Total Sales of Supply Chain (25)
- 1004. 成绩排名 (20)
- 语音学习笔记10------如何利用Deep CNN大幅提升识别准确率?
- 计算机硬件软件dos基础常识
- CentOS配置hadoop
- 进入某个目录需要什么权限
- 北邮OJ-97. 二叉排序树-12计院上机C
- shell脚本之if语句
- 小记SpringBoot使用方法