1106. Lowest Price in Supply Chain
来源:互联网 发布:mac双系统重装os x 编辑:程序博客网 时间:2024/05/17 22:05
一开始犯蠢输出直接p*(1+r/100)*(1+r/100)居然还过了两个测试点拿了15分哈哈,机智地骗分~
依旧乞丐版队列+乞丐版层次遍历。
#include <stdio.h>typedef struct tree {int first;int next;}tree;int main(){tree t[100000];int n, i, child_num, ID, Q[100000], front = 0, rear = 0, x, first = 0, cnt = 1, last = 1,retailer=0;double p, r;scanf("%d %lf %lf", &n, &p, &r);for (i = 0; i < n; i++) {t[i].first = -1;scanf("%d",&child_num);while (child_num--) {scanf("%d", &ID);t[ID].next = t[i].first;t[i].first = ID;}}Q[rear++] = 0;int level = 0,min_level=100001;while (front != rear) {x = Q[front++];first++;if (t[x].first == -1) {min_level = level;retailer++;}for (i = t[x].first; i != -1; i = t[i].next) {Q[rear++] = i;cnt++;}if (first == last) {level++;last = cnt;if (min_level < level)break;}}for (i = 0; i < min_level; i++)p *= (1 + r / 100);printf("%.4lf %d",p,retailer);return 0;}
0 0
- 1106. Lowest Price in Supply Chain (25)
- 1106. Lowest Price in Supply Chain (25)
- 1106. Lowest Price in Supply Chain (25)
- 1106. Lowest Price in Supply Chain (25)
- 1106. Lowest Price in Supply Chain (25)
- 1106. Lowest Price in Supply Chain (25)
- 1106. Lowest Price in Supply Chain (25)
- 1106. Lowest Price in Supply Chain
- 1106. Lowest Price in Supply Chain (25)
- 1106. Lowest Price in Supply Chain (25)
- 1106. Lowest Price in Supply Chain
- 1106. Lowest Price in Supply Chain (25)
- PAT--1106. Lowest Price in Supply Chain
- 1106. Lowest Price in Supply Chain (25)
- 1106. Lowest Price in Supply Chain (25)
- 1106. Lowest Price in Supply Chain (25)
- 【PAT】1106. Lowest Price in Supply Chain
- 1106. Lowest Price in Supply Chain
- CSU-1009
- Project Euler 014 Longest Collatz sequence
- 解释执行与编译执行的区别
- RocketMQ多Master多Slave模式部署
- innerHtml与innerText的区别
- 1106. Lowest Price in Supply Chain
- 全配置(无注释)aop例子
- Linux学习-2016_01_10
- ASP.NET MVC5 实现分页查询
- ansible host详解
- php面试题
- 第一篇博客
- 【bzoj 1002】 [FJOI2007]轮状病毒
- 教你用C#写计算机的牛逼写法