简单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. HyperSnap(屏幕抓图工具) 8.11.03 官方简体中文特别版

    软件名称:屏幕抓图工具HyperSnap 软件分类:图像捕捉运行环境:WinXP/Win2003/Vista/Win7/Win8/WinALL软件语言:简体中文授权方式:免费软件软件大小:12462K ...

  2. ural 1352. Mersenne Primes

    1352. Mersenne Primes Time limit: 1.0 secondMemory limit: 64 MB Definition. If the number 2N−1 is pr ...

  3. 3.编写BinIoDemo.java的Java应用程序,程序完成的功能是:完成1.doc文件的复制,复制以后的文件的名称为自己的学号姓名.doc。

    package zuoye; import java.io.FileInputStream; import java.io.FileOutputStream; public class BinIoDe ...

  4. 2.编写IoDemo.java的Java应用程序,程序完成的功能是:首先读取text.txt文件内容,再通过键盘输入文件的名称为iodemo.txt,把text.txt的内容存入iodemo.txt

    package zuoye; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; ...

  5. 工作线程基类TaskSvc

    工作线程基类TaskSvc 前端时间用ACE写代码,发ACE_Task确实好用.不但能提供数量一定的线程,还能够让这些继承的线程函数自由访问子类的private和protected变量.此外,ACE_ ...

  6. linux常用服务软件搭建及使用技巧

    一.Webmin安装: Webmin 是一个基于浏览器的管理工具,可以应用于Linux 和其他一些平台,提供了可以完成很多管理和操作任务的图形化界面 •安装完成后,root 用户会被自动创建,密码为系 ...

  7. inflate的使用注意事项

    public View inflate (int resource, ViewGroup root, boolean attachToRoot) 我们在使用这个方法时,要清楚原理,下面是这个方法的文档 ...

  8. <context:annotation-config/>

    转自:Spring <context:annotation-config/> 解说 在基于主机方式配置Spring的配置文件中,你可能会见到<context:annotation-c ...

  9. hdu_5800_To My Girlfriend(变种背包)

    题目链接:hdu_5800_To My Girlfriend 题意: 给你n和物品和一个重量m,让你求 题解: To My Girlfriend 令dp[i][j][s1][s2]表示前i个物品填了j ...

  10. hdu_4734_F(x)(数位DP水)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4734 题意:给你一个F(x)的定义,然后给你a,b,问你在0到b包括b有多少个数满足F(x)<= ...