当前位置:网站首页>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;
}
边栏推荐
- Without 50W bride price, my girlfriend was forcibly dragged away. What should I do
- Market status and development prospect prediction of the global fire extinguisher industry in 2022
- [luatos sensor] 1 light sensing bh1750
- Triangular rasterization
- Learning practice: comprehensive application of cycle and branch structure (I)
- Problems encountered in fuzzy query of SQL statements
- Uipath practice (08) - selector
- Market status and development prospect forecast of global heat curing adhesive industry in 2022
- [set theory] relationship properties (symmetry | symmetry examples | symmetry related theorems | antisymmetry | antisymmetry examples | antisymmetry theorems)
- LVS load balancing cluster of efficient multi-purpose cluster (NAT mode)
猜你喜欢
ZABBIX monitoring of lamp architecture (3): zabbix+mysql (to be continued)
Basic use of Metasploit penetration testing framework
The reason why the entity class in the database is changed into hump naming
Triangular rasterization
Shuttle + Alluxio 加速内存Shuffle起飞
Preparation for school and professional cognition
MPM model and ab pressure test
Do you know UVs in modeling?
[set theory] relation properties (reflexivity | reflexivity theorem | reflexivity | reflexivity theorem | example)
联发科技2023届提前批IC笔试(题目)
随机推荐
Wechat applet distance and map
Sdl2 + OpenGL glsl practice (Continued)
Number of 1 in binary (simple difficulty)
UiPath实战(08) - 选取器(Selector)
Number of uniform strings of leetcode simple problem
Market status and development prospect prediction of the global fire hose industry in 2022
带有注意力RPN和多关系检测器的小样本目标检测网络(提供源码和数据及下载)...
Review the old and know the new: Notes on Data Science
2022-02-12 daily clock in: problem fine brush
Huawei personally ended up developing 5g RF chips, breaking the monopoly of Japan and the United States
Preparation for school and professional cognition
Messy change of mouse style in win system
[SQL injection] joint query (the simplest injection method)
【XSS绕过-防护策略】理解防护策略,更好的绕过
Market status and development prospect forecast of global button dropper industry in 2022
C Primer Plus Chapter 10, question 14 3 × 5 array
String matching: find a substring in a string
Market status and development prospect prediction of global fermented plant protein industry in 2022
第十九届浙江省 I. Barbecue
[tools run SQL blind note]