当前位置:网站首页>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注入】联合查询(最简单的注入方法)
- Market status and development prospect prediction of the global forward fluorescent microscope industry in 2022
- [develop wechat applet local storage with uni app]
- Leetcode simple question: check whether two string arrays are equal
- Small sample target detection network with attention RPN and multi relationship detector (provide source code, data and download)
- I stepped on a foundation pit today
- [BMZCTF-pwn] 20-secret_ file
- [tools run SQL blind note]
- Unity tool Luban learning notes 1
- Market status and development prospect prediction of global colorimetric cup cover industry in 2022
猜你喜欢
![[research materials] 2021 China's game industry brand report - Download attached](/img/b7/a377b0b7c742078e2feb28ebfbca62.jpg)
[research materials] 2021 China's game industry brand report - Download attached

The reason why the entity class in the database is changed into hump naming

Retirement plan fails, 64 year old programmer starts work again

STM32 reverse entry

The principle is simple, but I don't know how to use it? Understand "contemporaneous group model" in one article

Truncated sentences of leetcode simple questions

移动端——uniapp开发记录(公共请求request封装)

Review the old and know the new: Notes on Data Science

The consumption of Internet of things users is only 76 cents, and the price has become the biggest obstacle to the promotion of 5g industrial interconnection
![[research materials] annual report of China's pension market in 2021 - Download attached](/img/24/622aeeb38de16ac84128b362ceeddb.jpg)
[research materials] annual report of China's pension market in 2021 - Download attached
随机推荐
The programmer resigned and was sentenced to 10 months for deleting the code. JD came home and said that it took 30000 to restore the database. Netizen: This is really a revenge
论文阅读_ICD编码_MSMN
The least operation of leetcode simple problem makes the array increment
Learn to use the idea breakpoint debugging tool
普通本科大学生活避坑指南
Market status and development prospect forecast of global heat curing adhesive industry in 2022
【SQL注入点】注入点出现位置、判断
Oracle SQL table data loss
Uipath practice (08) - selector
Literature reading_ Research on the usefulness identification of tourism online comments based on semantic fusion of multimodal data (Chinese Literature)
Three representations of signed numbers: original code, inverse code and complement code
The usage of micro service project swagger aggregation document shows all micro service addresses in the form of swagger grouping
MC Layer Target
Market status and development prospect prediction of the global fire extinguisher industry in 2022
Blog building tool recommendation (text book delivery)
Leetcode simple question: the key with the longest key duration
Market status and development prospect prediction of the near infrared sensor industry of the global Internet of things in 2022
Online VR model display - 3D visual display solution
Cross platform plug-in flutter for displaying local notifications_ local_ notifications
Market status and development prospects of the global autonomous marine glider industry in 2022