题意:

输入一个正整数N(<=1e5),和两个小数r和f,表示树的结点总数和商品的原价以及每向下一层价格升高的幅度。下一行输入N个结点的父结点,-1表示为根节点。输出最深的叶子结点处购买商品的价格以及有几个深度最深的结点。

AAAAAccepted code:

 #define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[];
vector<int>v[];
int mx;
int ans[];
void dfs(int x,int storey){
mx=max(mx,storey);
ans[x]=storey;
for(auto it:v[x])
dfs(it,storey+);
}
int main(){
int n;
int root=;
double p,r;
cin>>n>>p>>r;
for(int i=;i<=n;++i){
cin>>a[i];
if(a[i]==-)
root=i-;
else
v[a[i]].push_back(i-);
}
dfs(root,);
int num=;
for(int i=;i<n;++i)
if(ans[i]==mx)
++num;
double sum=p*pow(+r/100.0,mx);
printf("%.2lf %d",sum,num);
return ;
}

【PAT甲级】1090 Highest Price in Supply Chain (25 分)的更多相关文章

  1. PAT 甲级 1090 Highest Price in Supply Chain

    https://pintia.cn/problem-sets/994805342720868352/problems/994805376476626944 A supply chain is a ne ...

  2. PAT Advanced 1090 Highest Price in Supply Chain (25) [树的遍历]

    题目 A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)–everyone inv ...

  3. [建树(非二叉树)] 1090. Highest Price in Supply Chain (25)

    1090. Highest Price in Supply Chain (25) A supply chain is a network of retailers(零售商), distributors ...

  4. PAT 甲级 1079 Total Sales of Supply Chain (25 分)(简单,不建树,bfs即可)

    1079 Total Sales of Supply Chain (25 分)   A supply chain is a network of retailers(零售商), distributor ...

  5. 1090. Highest Price in Supply Chain (25) -计层的BFS改进

    题目如下: A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyon ...

  6. PAT甲级——A1090 Highest Price in Supply Chain

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

  7. 1090. Highest Price in Supply Chain (25)

    时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A supply chain is a network of r ...

  8. 1090 Highest Price in Supply Chain (25)(25 分)

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

  9. PAT (Advanced Level) 1090. Highest Price in Supply Chain (25)

    简单dfs. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...

随机推荐

  1. Book: The TimeViz Browser

    website; A visual survey of visualization techniques for time-oriented data. 1. Left pannel ----- fi ...

  2. PP: Time series clustering via community detection in Networks

    Improvement can be done in fulture:1. the algorithm of constructing network from distance matrix. 2. ...

  3. python pymysql 基本使用

    from pymysql import * # 1.创建连接数据库 conn = connect(host="localhost", port=3306, user="r ...

  4. Java基本语法--变量

    本篇博客主要介绍了Java基本语法中变量(variable)d的使用,变量是指内存中的一个存储区域,用于在内存中保存数据,在该区域的数据可以在同一类型范围内不断变化.变量是程序中最基本的存储单元.包含 ...

  5. 三、ZigBee无线网络工具

    CC2530概述 CC2530是德州仪器Ti公司用于2.4-GHz IEEE 802.15.4.ZigBee 和 RF4CE 应用的一个真正的片上系统(SoC)解决方案,是作为ZigBee无线传 感网 ...

  6. spring(三):BeanDefiniton

  7. ASP.NET + MVC5 入门完整教程三 (上) ---第一个MVC项目

    https://blog.csdn.net/qq_21419015/article/details/80420815 第一个MVC应用程序 1创建MVC项目 打开VS ,File--新建--项目,选择 ...

  8. 什么是nuget?nuget包是如何管理

    本文链接:https://blog.csdn.net/Microsoft_Mao/article/details/101159800做windows开发的,迟早会接触到nuget这个东西,那么今天我们 ...

  9. IMM设置静态ip,安装系统

    IMM设置静态ip,安装系统 设置ip: System Setting->Integrated Management Module->Network configuration 修改后选择 ...

  10. 前端框架vue.js系列(9):Vue.extend、Vue.component与new Vue

    前端框架vue.js系列(9):Vue.extend.Vue.component与new Vue 本文链接:https://blog.csdn.net/zeping891103/article/det ...