PAT-A1090
来源:互联网 发布:淘宝店哪家衣服质量好 编辑:程序博客网 时间:2024/05/20 15:39
#include<stdio.h>#include<vector>#include<queue>#include<math.h>using namespace std;int n, max_level=-1, sum=0;double p, r, ans=0;struct pnode{int level;vector<int> child;}node[100010];void levelorder(int root){node[root].level=0;queue<int> que;que.push(root);while(!que.empty()){int front=que.front();que.pop();if(node[front].level>max_level){max_level=node[front].level;sum=1;}else if(node[front].level=max_level){sum++;}for(vector<int>::iterator it=node[front].child.begin();it!=node[front].child.end();it++){node[*it].level=node[front].level+1;que.push(*it);}}//while}int main(){int i, temp, root;scanf("%d%lf%lf",&n,&p,&r);for(i=0;i<n;i++){ scanf("%d",&temp);if(temp==-1)root=i;else node[temp].child.push_back(i);}r=1+r/100;levelorder(root);printf("%0.2lf %d\n",p*pow(r,max_level),sum);return 0;}
0 0
- PAT-A1090
- PAT a1090题解
- PAT A1090 Highest Price in supply chain
- PAT A1090. Highest Price in Supply Chain (25)
- PAT A1090 highest price of supply chain(25)
- pat-a1090. Highest Price in Supply Chain (25)
- 刷清橙OJ--A1090.摆动序列
- A1090. Highest Price in Supply Chain (25)
- pat
- 【PAT】
- PAT
- PAT
- PAT
- PAT
- PAT
- PAT
- PAT
- PAT
- 《机器学习实战》第十章 :K-均值聚类算法
- 数据结构课程设计报告 二叉树的应用
- 网络编程socket基本API详解(转)
- 理解MP算法
- 北京传智播客最后一期Net就业
- PAT-A1090
- another app is currently holding the yum lock;waiting for it to exit
- 313. Super Ugly Number
- 【Codeforces Round #403】Codeforces 781D Axel and Marston in Bitland
- 一些有用的bash命令记录汇总
- Android:控件AutoCompleteTextView 自动提示
- SpringMVC + MyBatis + Mysql + Redis(作为二级缓存) 配置
- vc p2p demo
- 洛谷P1144 最短路计数(spfa)