当前位置:网站首页>L2-020 功夫传人 (25 分)
L2-020 功夫传人 (25 分)
2022-04-23 00:33:00 【hys__handsome】
题目详情 - L2-020 功夫传人 (25 分) (pintia.cn)
注意审题,这里计算的是得道者功力总和。
思路:本质是一棵树,得道者都是叶子结点,所以直接dfs到叶子结点并计算总和即可。
#include<iostream>
#include<vector>
using namespace std;
const int N = 100010;
vector<vector<int>> g(N);
int a[N];
double sum = 0;
void dfs(int x,double gl,double r){
if(g[x].empty()) sum += gl*a[x];
for(int num:g[x]){
dfs(num,gl*r,r);
}
}
int main(){
int n;
double z,r;
cin>>n>>z>>r;
for(int i = 0; i < n; i++){
int k; cin>>k;
if(k == 0) cin>>a[i];
for(int j = 0; j < k; j++){
int x; cin>>x;
g[i].push_back(x);
}
}
dfs(0,z,(100-r)/100);
cout<<(long long)sum;
return 0;
}
版权声明
本文为[hys__handsome]所创,转载请带上原文链接,感谢
https://blog.csdn.net/hys__handsome/article/details/124343620
边栏推荐
- Pain points solved by tidb under the wave of localization
- C console application flash when running solution
- Progrès de la recherche sur la télédétection des paramètres phénologiques de la végétation
- 多测师杭州拱墅校区肖sir_高级金牌讲师_简历制作讲解
- Process comma separated strings and sort the output in ascending dictionary order
- Node + mongoose paging effect
- C# WPF UI框架MahApps切换主题
- Simple use of Excel if function
- 国产化浪潮下TiDB解决的痛点问题
- 一场由TiCDC异常引发的GC不干活导致的Tikv硬盘使用问题
猜你喜欢

网线IP配置

EXCEL IF函数的简单使用

MySQL -- operation of database

MP2459被完美替代内部集成有功率MOSFET管FS2459的60V0.5A降压IC

Two methods are used to realize mongodb self increment ID, and the second one is recommended

Nodejs learning notes

ArcGIS 地表TIN面数据的符号化
![[image classification] reproduce senet with the shortest code. Xiaobai must be collected (keras, tensorflow2. X)](/img/f4/a063e2426ed3967e9a626ffb257d85.jpg)
[image classification] reproduce senet with the shortest code. Xiaobai must be collected (keras, tensorflow2. X)

Beifu scope view oscilloscope reads the signal of configuration IO

ArcGIS TIN地表面与栅格地表面的生成与互相转换
随机推荐
According to this effective method, UI automation testing is so simple
我和TiDB的故事 | 毫无准备地不期而遇,却想说与你相遇好幸运
智能无线传输模组,CV5200助力无人机mesh组网,无线通信传输方案
Usage of while (n -- > 0)
Beginner MCU lights up the first peripheral -- led light
(turn) install any version of on win10 net framework
El2124 module wiring and pin meaning
Error runtimeerror when MySQL runs workbench
Nodejs + Express login authentication and registration
ArcGIS urban living area land suitability evaluation (V)
多测师肖sir_高级金牌讲师_面试题
【图像分类】用最简短的代码复现SeNet,小白一定要收藏(keras,Tensorflow2.x)
24V~48V磁吸轨道灯FS2459替代MP2459方案
idea中使用thymeleaf 模板 <img th:src=“${map.user.headerUrl}“ 报错Cannot resolve ‘user‘
c#可变参数params的介绍
Mp2459 is a perfect replacement for 60v0 with power MOSFET fs2459 integrated inside 5A step-down IC
ACWing春季每日一题——你知道ABC吗
repeat_ map mp. find() + mp. erase()
Addition, deletion, modification and query of MySQL table (Advanced)
Add a route between two CX controllers of Beifu