当前位置:网站首页>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;
}
边栏推荐
- Thesis reading_ Tsinghua Ernie
- Handling record of electric skateboard detained by traffic police
- Coordinatorlayout appbarrayout recyclerview item exposure buried point misalignment analysis
- What is UUID
- Shuttle + alluxio accelerated memory shuffle take-off
- Shuttle + Alluxio 加速内存Shuffle起飞
- On typescript and grammar
- [USACO 2009 Dec S]Music Notes
- The 19th Zhejiang I. barbecue
- Market status and development prospect prediction of the global fire alarm sensor industry in 2022
猜你喜欢
Source insight garbled code solution
The usage of micro service project swagger aggregation document shows all micro service addresses in the form of swagger grouping
[Yu Yue education] basic reference materials of interchangeability and measurement technology of Zhongyuan Institute of Technology
Thesis reading_ ICD code_ MSMN
Leetcode simple question: check whether the array is sorted and rotated
Introduction to message queuing (MQ)
【工具跑SQL盲注】
论文阅读_清华ERNIE
MediaTek 2023 IC written examination approved in advance (topic)
7. Integrated learning
随机推荐
Mount NFS in kubesphere
Concurrent operation memory interaction
Use Sqlalchemy module to obtain the table name and field name of the existing table in the database
[develop wechat applet local storage with uni app]
Notes | numpy-09 Broadcast
Sprintf formatter abnormal exit problem
M1 Pro install redis
Interface frequency limit access
[research materials] 2022q1 game preferred casual game distribution circular - Download attached
Market status and development prospect prediction of global fermented plant protein industry in 2022
Basic use of Metasploit penetration testing framework
Leetcode simple question: check whether two string arrays are equal
[research materials] 2021 annual report on mergers and acquisitions in the property management industry - Download attached
[PHP vulnerability weak type] basic knowledge, PHP weak equality, error reporting and bypassing
Silent authorization login and registration of wechat applet
Notes | numpy-07 Slice and index
RT thread flow notes I startup, schedule, thread
LVS load balancing cluster of efficient multi-purpose cluster (NAT mode)
Shell script Basics - basic grammar knowledge
[set theory] relation properties (reflexivity | reflexivity theorem | reflexivity | reflexivity theorem | example)