当前位置:网站首页>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;
}边栏推荐
- 并发操作-内存交互操作
- [SQL injection point] location and judgment of the injection point
- Market status and development prospect prediction of global colorimetric cup cover industry in 2022
- The reason why the entity class in the database is changed into hump naming
- Sdl2 + OpenGL glsl practice (Continued)
- M1 Pro install redis
- Market status and development prospects of the global automatic tea picker industry in 2022
- SSM framework integration
- 联发科技2023届提前批IC笔试(题目)
- Valentine's day limited withdrawal guide: for one in 200 million of you
猜你喜欢

并发操作-内存交互操作

Silent authorization login and registration of wechat applet

Leetcode simple question: check whether the array is sorted and rotated
![[Yu Yue education] basic reference materials of interchangeability and measurement technology of Zhongyuan Institute of Technology](/img/f1/d0dc4dc3fe49a2d2cd9e452a0ce31e.jpg)
[Yu Yue education] basic reference materials of interchangeability and measurement technology of Zhongyuan Institute of Technology

Review the configuration of vscode to develop golang

Analysis of proxy usage of ES6 new feature
![[set theory] relation properties (reflexivity | reflexivity theorem | reflexivity | reflexivity theorem | example)](/img/2a/362f3b0491f721d89336d4f468c9dd.jpg)
[set theory] relation properties (reflexivity | reflexivity theorem | reflexivity | reflexivity theorem | example)

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

Number of uniform strings of leetcode simple problem

Flutter monitors volume to realize waveform visualization of audio
随机推荐
Market status and development prospects of the global autonomous marine glider industry in 2022
Preparation for school and professional cognition
Handling record of electric skateboard detained by traffic police
Thesis reading_ Chinese NLP_ ELECTRA
Current market situation and development prospect forecast of global UV sensitive resin 3D printer industry in 2022
【PHP漏洞-弱类型】基础知识、php弱相等、报错绕过
Market status and development prospect prediction of the global fire alarm sensor industry in 2022
Handler understands the record
Leetcode simple question: check whether two string arrays are equal
Network security textual research recommendation
On typescript and grammar
Notes | numpy-10 Iterative array
[USACO 2009 Dec S]Music Notes
The process of browser accessing the website
论文阅读_ICD编码_MSMN
Do you know UVs in modeling?
Market status and development prospect forecast of global button dropper industry in 2022
Silent authorization login and registration of wechat applet
The 19th Zhejiang I. barbecue
[research materials] annual report of China's pension market in 2021 - Download attached