PAT a1079题解
来源:互联网 发布:java伪代码怎么写 编辑:程序博客网 时间:2024/05/20 07:52
#include <cstdio>#include <cmath>#include <vector>using namespace std;const int maxn = 100010;struct node{double data;vector<int> child;}Node[maxn];int n;double p, r, ans = 0;void DFS(int index, int depth){if(Node[index].child.size() == 0){ans += Node[index].data * pow(1 + r, depth);return;}for(int i = 0; i < Node[index].child.size(); i++){DFS(Node[index].child[i], depth + 1);}} int main(){int k, child;scanf("%d%lf%lf", &n, &p, &r);r /= 100;for(int i = 0; i < n; i++){scanf("%d", &k);if(k == 0){scanf("%lf", &Node[i].data);} else{for(int j = 0; j < k; j++){scanf("%d", &child);Node[i].child.push_back(child);}}} DFS(0, 0);printf("%.1f\n", p * ans);return 0;}
阅读全文
1 0
- PAT a1079题解
- PAT A1079
- PAT-A1079
- PAT A1079. Total Sales of Supply Chain (25)
- PAT A1079 tota sales of supply chain (25)
- PAT 1001-1010 题解
- PAT 1011-1020 题解
- PAT 1021-1030 题解
- PAT 1031-1040 题解
- PAT 1041-1050 题解
- PAT 1051-1060 题解
- PAT(basic level)题解
- PAT乙级题解
- PAT题解目录
- PAT甲级题解目录
- PAT乙级题解目录
- PAT甲级1001题解
- PAT甲级1002题解
- vscode编辑器——编译调试小问题
- 游戏开发行业,前景如何?需要哪些技术?
- 【c++】深浅拷贝,引用计数写时拷贝
- Android 绘制多个连续带数字圆圈。
- 【C++】【日志贴】浅谈标准库类型string、vector及C风格字符串在全局和局部作用域中默认初始值情况
- PAT a1079题解
- PAT a1080题解
- PAT a1081题解
- Android高级控件
- 网易云JAVA入门编程题7-1
- RedHat Enterprise 6.5安装Oracle 12.2.0.1
- navicat连接腾讯云MySQL
- ACM_08
- App调用系统Camera拍照或者从Gallery选取图片,返回时先显示手机Launcher或者前一个界面,再跳转到当前activity