1079 Total Sales of Supply Chain (25 point(s))

十大物流仿真软件汇总 这里写自定义目录标题(一) Flexsim(二) RaLC(乐龙)(三) Witness(SDX)(四) Automod(五) ShowFlow(六) SIMAnimation(七) Arena(八) Supply chain guru(九) Classwarehouse(十) SimLab (一) Flexsim Flexsim是美国的三维物流仿真软件,能应用于系统建模、仿真以及实现业务流程可视化.Flexsim中的对象参数可以表示基本上所有的存在的实物对象,如机器装备、操作人员、传送带、叉车、仓库、集装 阅读详情

1079 Total Sales of Supply Chain (25 point(s))

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 (≤10​5​​), 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:

K​i​​ ID[1] ID[2] ... ID[K​i​​]

where in the i-th line, K​i​​ 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. K​j​​ being 0 means that the j-th member is a retailer, then instead the total amount of the product will be given after K​j​​. 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 10​10​​.

Sample Input:

10 1.80 1.00
3 2 3 5
1 9
1 4
1 7
0 7
2 6 1
1 8
0 9
0 4
0 3

Sample Output:

42.4

关键点:BFS计算树的层次。

 注意:init()是必要的,否则case#5会TLE(22分)。

//bfs 
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#define LL long long
using namespace std;
const int MAX = 1e5+7;
vector<int> graph[MAX];
int level[MAX]={0};
bool visit[MAX]={false};
int cnt[MAX]={0};
queue<int> q;
void bfs(int root){
	q.push(root);
	visit[root]=true;
	while(!q.empty()){
		int top = q.front();
		q.pop();
		for(int i=0;i<graph[top].size();i++){
			int cur = graph[top][i];
			if(!visit[cur]){
				visit[cur]=true;
				level[cur]=level[top]+1;
				q.push(cur);
			}
		} 
	}
}
double price[MAX];
void init(double p,double r){
	price[0]=p;
	for(int i=1;i<MAX;i++){
		price[i]=price[i-1]*(1+0.01*r);
	}
}
int main(void){
	int n;double p,rate;
	cin>>n>>p>>rate;
	int a,b;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a==0){
			cin>>b;
			cnt[i]=b;
		}else{
			while(a--){
				cin>>b;
				graph[i].push_back(b);
				graph[b].push_back(i);
			}
		}
	}
	bfs(0);
	init(p,rate);
	double ans = 0;
	for(int i=0;i<n;i++){
		if(cnt[i]>0){
			ans += double(cnt[i])*price[level[i]];
		}
	}
	printf("%.1f\n",ans);
	return 0;
}

Note

2019/09/01 由于树是单向的,并不必要存储成双向图,自然地没有必要维护visit[]。参考1106。

Supply_Chain_Guru选址 Supply Chain Guru is cutting edge software that allows you to perform both supply chain simulation and optimization. This enables you to directly solve problems involving supply chain strategic planning. Time and financial resources can be more closely examined for long-term planning and growth opportunities. Scenarios can be effectively tested for their potential prior to commitment. All these valuable features are in an easy to manage windows-based environment. 立即下载

相关推荐

supply-chain

供应链和数据审核 该存储库包含一个以太坊DApp,该DApp演示了卖方和买方之间的供应链流程。用户故事类似于任何常用的供应链流程。卖方可以将项目添加到存储在区块链中的库存系统中。买方可以从库存系统中购买此类物品。此外,卖方可以将物料标记为已发货,而买方可以将物料标记为已收货。 运行时的DApp用户界面应类似于... 入门 这些说明将为您提供在本地计算机上运行并运行的项目的副本,以进行开发和测试。有关如何在实时系统上部署项目的注释,请参阅部署。 先决条件 请确保您已经在浏览器中安装了ganache-cli,Truffle并启用了MetaMask扩展。 Give examples (to be clarified) 正在安装 一系列循序渐进的示例,告诉您必须运行开发环境 克隆此存储库: git clone https://github.com/udacity/nd1309/tree/mas

PAT 甲级 1079 Total Sales of Supply Chain(25 分)

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

宝付支的博客 484

showflow

showflow

供应链管理系统软件有哪些?这几款软件很不错

企业不断引进各类管理理念,落地运用各种信息化系统,然而依旧问题频出:核心问题在于:管理理念改革、数字化转型等都是从应用层解决问题,而没有从源头出发。企业的成本、质量、交付、库存源头本质上都是由供应商决定的,企业内部的各种改革只能说治标不治本。从企业经营管理者的视角看,补强供应链管理短板,提升广大供应商的管理水平,是企业面对市场竞争中,快速取得品质、效率、成本、创新等方面差异化优势的有效手段。供应商管理水平低,待提升空间大,反而是企业经营管理者所面对的一座未被挖掘的金矿。而专业的供应商管理系统,不仅能实现供应

jdyzzy的博客 2383

明基逐鹿软件Guru解决方案

明基逐鹿软件所提供的分销供应链软件是一套充分考虑现代分销企业所面临的难题,集电子网络定单、销售、采购、库存、渠道管理、维修服务、物流执行及财务管理功能为一身的全套解决方案。

hi3516cv610在PQStream上实现拉出图像,windows和板端操作记录

PQStream拉出图像

weixin_51838255的博客 730

1079 Total Sales of Supply Chain (25point(s))

1079 Total Sales of Supply Chain (25point(s)) 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 buy

佳迪斯的博客 180

AGI 之 【Dify】 之 Dify 在 Windows 端本地部署调用 Ollama 本地下载的大模型, API 形式 Python 调用 进行简单聊天接口测试

AGI,即通用人工智能(Artificial General Intelligence),是一种具备人类智能水平的人工智能系统。它不仅能够执行特定的任务,而且能够理解、学习和应用知识于广泛的问题解决中,具有较高的自主性和适应性。AGI的能力包括但不限于自我学习、自我改进、自我调整,并能在没有人为干预的情况下解决各种复杂问题。本节将介绍如何使用 Dify 平台调用 Ollama 部署的本地模型来创建一个聊天应用。通过 API 的方式发起聊天,可以让前端自由布置所需的聊天形式。

仙魁XAN 1万+

1079 Total Sales of Supply Chain (25 point(s))

题解 dfs. #include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;vector&gt; #include&lt;cmath&gt; using namespace std; struct node { double product; vector&lt;int&gt; dist; }; double res, r,...

徐伯莱 326

基于任务的功能磁共振成像的连接性分析

虽然这种方法通过减少偶然只选择特异性代表的可能性来改善可推广性,但类别内和类别间的变异性变得更难控制(例如,"鸟类"可能是一个比"车辆"更加/不那么同质的类别),并且可能会出现关于这些预定义类别是否是现实世界实体的有意义划分的担忧——尽管这个限制在某种程度上可以通过表征相似性分析来解决。特别是,海马单变量激活和语义认知区域(左下额回)中语义信息的表征强度之间的交互预测了项目的概念记忆,而海马单变量激活和视觉处理区域(腹内侧枕叶皮层)中视觉属性的表征强度之间的交互预测了图像样本的知觉记忆。

cc1609130201的博客 2231

echarts如何实现3D饼图(环形图)?

自定义修改3D饼图的宽高和legend

i-cat的博客 1万+

1079 Total Sales of Supply Chain (25 point(s)) PAT甲级

1079 Total Sales of Supply Chain (25 point(s)) dfs 题目 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 c

neko的博客 236

yolov8x-p2 实现 tensorrt 推理

yolov8x-p2, tensorrt 实现.

J。 2274

1079 Total Sales of Supply Chain (25 point(s))

matter DFS的作用:遍历整个树,求树的深度 code #include<iostream> #include<vector> #include<cmath> using namespace std; const int MAXN = 100005; double P , R , ans; struct node{ int num; vec...

Bonstoppo 153

PCIe 互联的芯片-- P2P(Peer-to-Peer)

PCIe设备间支持P2P直连通信,但需满足硬件、固件和软件三方面条件。硬件需CPU/芯片组和PCIe交换器支持P2P,BIOS需开启相关设置,操作系统和驱动也要适配。消费级GPU通常禁用此功能,且PCIe P2P性能(128GB/s带宽)远低于NVLink(900GB/s)。常见限制包括ACS阻断、IOMMU隔离和带宽瓶颈。可通过nvidia-smi或NCCL测试验证P2P是否生效。该技术适合异构设备通信,但需注意配置调优。

MHD0815的博客 684

Android 12.0 系统开机设置默认横屏显示

在12.0的系统产品开发中,对于产品需求来说,由于是宽屏设备所以产品需要开机默认横屏显示,开机横屏显示这就需要从两部分来实现,一部分是开机动画横屏显示,另一部分是系统显示横屏显示,从这两方面就可以做到开机默认横屏显示了。

安卓兼职framework和app工程师的博客 3744

1079 Total Sales of Supply Chain (25point(s)) - C语言 PAT 甲级

价格仅和叶节点层数有关,所以利用并查集的思想,记录每个节点的父节点,以递推出叶节点的层数 * level[v] = get_level(father[v]) + 1,要用数组 level 记录层级信息,不记录的话每次都查询到根节点,会超时 * 根节点 level[0] = 0

有三只土豆 427

史上最详细的sqlmap使用教程

sqlmapsqlmap是一个自动化的SQL注入工具,其主要功能是扫描,发现并利用给定的URL进行SQL注入。目前支持的数据库有MySql、Oracle、Access、PostageSQL、SQL Server、IBM DB2、SQLite、Firebird、Sybase和SAP MaxDB等Sqlmap采用了以下5种独特的SQL注入技术基于布尔类型的盲注,即可以根据返回页面判断条件真假的注入。

大河之犬的博客 5万+

PAT A1079 Total Sales of Supply Chain (25 point(s))

题目 Code #include #include #include #include using namespace std; const int maxn=100100; struct node{ double data; vector child; }Node[maxn]; int n; double p,r,ans=0; void DFS(int index,int depth...

Decmxj1229的博客 260

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

PAT A1079 Total Sales of Supply Chain (25point(s))

题目链接 思路:本题就是计算树根节点权值与深度幂的乘积之和,可以用DFS遍历树也可以用BFS遍历树,区别在于DFS的深度是通过函数参数传递,而BFS的深度保存在在结点结构体的元素中。下面是DFS的代码: #include<cstdio> #include<vector> #include<cmath> using namespace std; double p,...

皮皮瓜的博客 174

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

PAT(甲级)1079 Total Sales of Supply Chain (25point(s))

题目 题目链接 思路 题目大意:所有的货物都出自一个供货者,他出售的价格为p,然后卖给若干个经销商,经销商可以再次卖给经销商,价格提高进价的r%,最后一直到零售商的手里,零售商再卖给消费者; 为每个中间商定义一个结构体,如果child 为零,说明是零售商,此时需要计算他把手里所有商品卖出后的总收益; 如何计算每一个零售商的总收益,因为每经过一个中间商价格会增加 r%,所以可以算出零售商的深度(即叶子结点所在的深度,意味着转了几个中间商),最终收益 = 货物总量 * 供应商价格 * (1 + r%)^(叶子

hjyp的博客 210

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

PAT----A1079 Total Sales of Supply Chain (25point(s))

A1079 Total Sales of Supply Chain (25point(s)) 题意 给出供应商、经销商、零售商组成的一棵树,和零售商销售的商品数,上一层向下一层以高于 %r 的价格销售商品,输出所有零售商的总共收入。 思路 dfs 总结 Sample Input: 10 1.80 1.00 3 2 3 5 1 9 1 4 1 7 0 7 2 6 1 1 8 0 9 0 4 0 3 ...

qq_43578870的博客 196

PAT_甲级_1079 Total Sales of Supply Chain (25point(s)) (C++)【DFS/scanf接受double】

目录 1,题目描述 题目大意 输入 2,思路 数据结构 算法 3,AC代码 4,解题过程 第一搏 1,题目描述 Sample Input: 10 1.80 1.00 3 2 3 5 1 9 1 4 1 7 0 7 2 6 1 1 8 0 9 0 4 0 3 Sample Output: 42.4 题目大意 有一个供应链,商品从供应商中出手,到达各...

&再见萤火虫&的博客 520

1079 Total Sales of Supply Chain (25 分)

题目链接 树的深搜 #include<bits/stdc++.h> using namespace std; const int maxn = 1e5+5; vector<int> v[maxn]; int mut[maxn]={0}; double t=0; void dfs(int r,double p, double c){ if(mut[r] !=0 ){ ...

姚军 207

1079 Total Sales of Supply Chain(25 分)

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

galesaur_wcy 310
上一篇: 1120 Friend Numbers (20 point(s))
下一篇: 1039 Course List for Student (25 point(s))
coderwait
博客等级 码龄9年 20粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值