简单dfs

#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std; const int maxn=+;
vector<int>g[maxn];
int n;
double P,r;
int ans_count=;
double ans_price=; void dfs(int x,double price)
{
if(g[x].size()==)
{
if(price<ans_price)
{
ans_count=;
ans_price=price;
}
else if(price==ans_price) ans_count++;
return;
} for(int i=;i<g[x].size();i++)
{
dfs(g[x][i],price*(+r/));
}
} int main()
{
scanf("%d",&n);
scanf("%lf%lf",&P,&r);
for(int i=;i<n;i++)
{
int num; scanf("%d",&num);
while(num--)
{
int x; scanf("%d",&x);
g[i].push_back(x);
}
} dfs(,P); printf("%.4lf %d\n",ans_price,ans_count); return ;
}

PAT (Advanced Level) 1106. Lowest Price in Supply Chain (25)的更多相关文章

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

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

  2. 【PAT甲级】1106 Lowest Price in Supply Chain (25分)

    题意:输入一个正整数N(<=1e5),两个小数P和R,分别表示树的结点个数和商品原价以及每下探一层会涨幅的百分比.输出叶子结点深度最小的商品价格和深度最小的叶子结点个数. trick: 测试点1 ...

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

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

  4. PAT Advanced 1106 Lowest Price in Supply Chain (25) [DFS,BFS,树的遍历]

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

  5. 1106. Lowest Price in Supply Chain (25)

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

  6. PAT甲题题解-1106. Lowest Price in Supply Chain (25)-(dfs计算树的最小层数)

    统计树的最小层数以及位于该层数上的叶子节点个数即可. 代码里建树我用了邻接链表的存储方式——链式前向星,不了解的可以参考,非常好用: http://www.cnblogs.com/chenxiwenr ...

  7. PAT (Advanced Level) 1079. Total Sales of Supply Chain (25)

    树的遍历. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...

  8. PAT甲级——1106 Lowest Price in Supply Chain(BFS)

    本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90444872 1106 Lowest Price in Supp ...

  9. PAT 1106 Lowest Price in Supply Chain

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

随机推荐

  1. 2.3 DHC REST

    DHC REST也是Chrome浏览器的插件,可以在Chrome应用商店安装下载,主要用来模拟HTTP客户端发送测试数据到服务器.HTTP Get请求在开发中比较常用.

  2. Yii2.0 多条件搜索 带分页

                                   方法一   在控制器中 ; if($titles!=""){ $where.=" and title lik ...

  3. GitHub上有很多不错的iOS开源项目

    GitHub上有很多不错的iOS开源项目,个人认为不错的,有这么几个:1. ReactiveCocoa:ReactiveCocoa/ReactiveCocoa · GitHub:GitHub自家的函数 ...

  4. js解析php返回的json数据无法获取length的问题分析

    1.问题出现的过程,js解析php json_encode 的数据,无法获取长度信息,提示undefined   debug:       首先打印查看了php encode后的数据,返现最外层是一个 ...

  5. django搭建Bootstrap常用问题解决方法

    1.进入页面,提示Creating a ModelForm without either the 'fields' attribute or the 'exclude'时 解决方法:打开forms.p ...

  6. VBS基础篇 - 对象(7) - TextStream对象

    VBS基础篇 - 对象(7) - TextStream对象   TextStream对象是用于访问文本文件的对象,它是FileSystemObject一个独立的附属对象,但在使用TextStream对 ...

  7. H5页面适配所有iPhone和安卓机型的六个技巧

    http://www.th7.cn/web/html-css/201605/166006.shtml http://www.th7.cn/web/html-css/201601/153127.shtm ...

  8. 《JS权威指南学习总结--3.4null和undefined》

    内容要点 一.相似性  var a= undefined;       var b= null;       if(a==b){           alert("相等");   ...

  9. LeetCode OJ 189. Rotate Array

    Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array  ...

  10. iOS 开发者旅途中的指南针 - LLDB 调试技术

    文章转载于:iOS 开发者旅途中的指南针 - LLDB 调试技术 今天给大家介绍的内容,无关乎任何功能性开发技术,但又对开发的效率影响至深,这就是调试技术. 何为调试呢,比如我们用 print 函数在 ...