当前位置:网站首页>1106 lowest price in supply chain (25 points)
1106 lowest price in supply chain (25 points)
2022-07-03 04:55:00 【vs5】
The main idea of the topic : Supplier is the root node , Retailers are leaf nodes , Supply goods from top to bottom , Each time the price of the next floor will rise r%, Ask for the lowest price to sell , And the quantity of this price .
bfs,dfs Fine , Find out that this tree is the minimum depth of the retailer , And the minimum depth of this node number .
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
vector<int>v[100010];
int minh = 1e9,sum;
void dfs(int u,int h)
{
if(h > minh) return ;
if(v[u].size() == 0) // Retailer
{
if(minh > h) minh = h,sum = 1; // Minimum depth
else if(minh == h) sum ++;// At the same depth
}
for(int i = 0; i < v[u].size(); i ++) dfs(v[u][i],h + 1);
}
int main()
{
int n;double p,r;
cin >> n >> p >> r;
for(int i = 0; i < n; i ++)
{
int k;
cin >> k;
for(int j = 0 ; j < k; j ++)
{
int a;
cin >> a;
v[i].push_back(a);
}
}
dfs(0,0);
printf("%.4lf %d",p * pow(1 + r / 100,minh),sum);
return 0;
}边栏推荐
- Mount NFS in kubesphere
- Unity tool Luban learning notes 1
- Valentine's day limited withdrawal guide: for one in 200 million of you
- What is UUID
- 雇佣收银员(差分约束)
- [BMZCTF-pwn] 18-RCTF-2017-Recho
- Sprintf formatter abnormal exit problem
- 【XSS绕过-防护策略】理解防护策略,更好的绕过
- Online VR model display - 3D visual display solution
- Number of 1 in binary (simple difficulty)
猜你喜欢

The simple problem of leetcode: dismantling bombs

Learn to use the idea breakpoint debugging tool

The least operation of leetcode simple problem makes the array increment

Basic use of Metasploit penetration testing framework

2022-02-11 daily clock in: problem fine brush

Leetcode simple question: the key with the longest key duration

带有注意力RPN和多关系检测器的小样本目标检测网络(提供源码和数据及下载)...

Learning practice: comprehensive application of cycle and branch structure (I)

Unity tool Luban learning notes 1

LVS load balancing cluster of efficient multi-purpose cluster (NAT mode)
随机推荐
MySQL winter vacation self-study 2022 12 (3)
Network security textual research recommendation
Hire cashier (differential constraint)
Basic use of Metasploit penetration testing framework
论文阅读_ICD编码_MSMN
[XSS bypass - protection strategy] understand the protection strategy and better bypass
Concurrent operation memory interaction
[PCL self study: filtering] introduction and use of various filters in PCL (continuously updated)
[tools run SQL blind note]
论文阅读_清华ERNIE
MediaTek 2023 IC written examination approved in advance (topic)
Problems encountered in fuzzy query of SQL statements
I've seen a piece of code in the past. I don't know what I'm doing. I can review it when I have time
Prepare for 2022 and welcome the "golden three silver four". The "summary of Android intermediate and advanced interview questions in 2022" is fresh, so that your big factory interview can go smoothly
[set theory] relational representation (relational matrix | examples of relational matrix | properties of relational matrix | operations of relational matrix | relational graph | examples of relationa
[develop wechat applet local storage with uni app]
Preparation for school and professional cognition
Handling record of electric skateboard detained by traffic police
2022-02-11 daily clock in: problem fine brush
The usage of micro service project swagger aggregation document shows all micro service addresses in the form of swagger grouping