1、题目类型:贪心、枚举。

2、解题思路:(1)对于每个 device 的多种选择,按照其 prices 从小到大排序;(2)遍历所有 device 中的每一种选择,寻找符合条件的最小B/P。

3、注意事项:注意STL结构体压栈;注意实数精度输出;注意遍历某种情况时,其他 device 不满足的情况。

3、实现方法:

1 #include <iostream>
2 #include <vector>
3 #include <algorithm>
4 using namespace std;
5
6 typedef struct{
7 int B;
8 int P;
9 }Device;
10
11 vector< vector<Device> > devices;
12
13 bool Cmp(const Device &dev1,const Device &dev2)
14 {
15 return dev1.P<dev2.P;
16 }
17
18 //选择第row个设备的第col种情况
19 double MaxBP(int row,int col)
20 {
21 int i,j;
22 int minBandwidth=devices[row][col].B;
23 int n=devices.size();
24 double sum=devices[row][col].P;
25 for(i=0;i<n;i++)
26 {
27 if(i==row) continue;
28 int m=devices[i].size();
29 for (j=0;j<m;j++)
30 {
31 if(devices[i][j].B >= minBandwidth)
32 {
33 sum += devices[i][j].P;
34 break;
35 }
36 //devices[i]中没有找到
37 if( j==m-1 )
38 return 0;
39 }
40 }
41 return minBandwidth/sum;
42 }
43
44 double Search()
45 {
46 double max = 0;
47 int i,j;
48 int n=devices.size();
49 for(i=0;i<n;i++)
50 {
51 int m=devices[i].size();
52 for(j=0;j<m;j++)
53 {
54 double bp=MaxBP(i,j);
55 if( bp>max )
56 max=bp;
57 }
58 }
59 return max;
60 }
61
62 int main()
63 {
64 int i,j,k,n,m,t;
65 cin>>t;
66 for(i=0;i<t;i++)
67 {
68 devices.clear();
69 cin >> n;
70 for (j=0;j<n;j++)
71 {
72 vector<Device> v;
73 cin>>m;
74 for(k=0;k<m;k++)
75 {
76 Device d;
77 cin >> d.B;
78 cin >> d.P;
79 v.push_back(d);
80 }
81 sort(v.begin(),v.end(),Cmp);
82 devices.push_back(v);
83 }
84 cout.setf (ios::fixed);
85 cout.precision (3);
86 cout<<Search()<<endl;
87 }
88 return 0;
89 }

转载于:https://www.cnblogs.com/yongze103/archive/2010/04/28/1723259.html

Communication System--ZOJ 1409相关推荐

  1. TargetVue: Visual Analysis of Anomalous User Behaviors in Online Communication System

    论文传送门 视频 作者 IBM T.J. Watson 研究中心 Nan Cao Conglei Shi Sabrina Lin Jie Lu Ching-Yung Lin 匹兹堡大学 Yu-Ru L ...

  2. POJ 1018 Communication System

    WA 的分析 1. solve_dp 返回的是 double 不是 int 浪费了非常久的时间 2. 做动规, 当状态转移方程比较复杂时, 举例子能够帮助初始化和写出状态转移方程 总结 1. 这里 d ...

  3. poj1018 Communication System (有道翻译完全拯救不了)

    译文: 问题描述 我们刚刚收到了来自PCI的一份订单 该系统由几个设备组成.对于每一个设备,我们可以自由选择由哪些制造商制造.相同的设备,不同的制造商都有不同的带宽和价格. B表示能达到的最小带宽之和 ...

  4. poj 1018 Communication System

    首先做这个题是极其难受的,第一次去做dp的题,万事开头难,虽然以前也接触过dp,但是都极力躲避着用其他算法解决,现在专门练这部分,倒觉得,你拍什么,什么就会比想象中难很多,没办法,一点一点练吧! 题意 ...

  5. MATLAB Communication System(4)通信系统的信源与信道一

    1.信源产生函数 1.1产生误比特图样:randerr 对于所有的语法,randerr对out的每一行都进行独立处理. out = randerr(m) 生成一个m乘m的二进制矩阵,其中每一行在随机位 ...

  6. POJ ZOJ题目分类

    POJ,ZOJ题目分类(多篇整合版,分类很细致,全面) 标签: 题目分类POJ整理 2015-04-18 14:44 1672人阅读 评论(0) 收藏 举报 本文章已收录于: 分类: ACM资料(5) ...

  7. POJ,ZOJ题目分类(多篇整合版,分类很细致,全面)

    水题: 3299,2159,2739,1083,2262,1503,3006,2255,3094 初级: 一.基本算法:        (1)枚举 (1753,2965)       (2)贪心(13 ...

  8. ZOJ 题目分类,学校的一个巨巨做的。

     DP: 1011      NTA                    简单题 1013      Great Equipment        简单题 1024      Calendar ...

  9. Turbo Autoencoder: Deep learning based channel code for point-to-point communication channels

    Turbo Autoencoder: Deep learning based channel code for point-to-point communication channels Abstra ...

  10. The development history and future trend of optical fiber communication technology

    The development history and future trend of optical fiber communication technology name:Puaoran (蒲傲然 ...

最新文章

  1. python爬虫数据分析可以做什么-python爬虫爬取的数据可以做什么
  2. Deep Reinforcement Learning 深度增强学习资源
  3. 单片机I/O口推挽输出与开漏输出的区别(open-drain与push-pull)
  4. ATOM editor recommended by Sean
  5. Tomcat安装后没有出现tomcat主页
  6. spark sql python_Spark 3.0开发近两年终于发布,流、Python、SQL重大更新详解
  7. Redis 和 memcached 区别
  8. linux谷歌浏览器无法登陆,使用chrome/chrominum浏览器无法正常登陆deepin论坛的解决...
  9. android模拟器root权限获取,如何在Android模拟器上获得root访问权限?
  10. 语音合成 g2p 字典设计
  11. html简单情侣对话
  12. 字节跳动Go 语言面试会问哪些问题?
  13. 如何解决Mathtype在Word中功能区是灰色的情况
  14. 北大青鸟所有学习资料下载地址
  15. Openwrt 分流-缓存-去广告
  16. 用Python进行训练/测试集分割和交叉验证
  17. 教师考计算机哪个,教师上岗证要考哪个些,计算机专业
  18. 生物医学关键词及基础知识学习笔记
  19. 《金融电子化》:隐私计算赋能银行助贷业务自主风控 | 华夏银行×洞见科技
  20. nltk_data下载错误 Error loading stopwords urlopen error [Errno 11004] 解决办法

热门文章

  1. CR(code review)常见问题
  2. bootstrap treetable 树形网格,动态扩展,连数据库
  3. PKCS #1 RSA Encryption Version 1.5
  4. 织梦新建顶级栏目打不开,解决办法
  5. html5 移动端单页面布局
  6. 采用docker安装部署Nginx
  7. java fx 重绘_如何重绘JAVA FX 2.2中的窗口(舞台)
  8. c语言张振国实验报告,基于VisualC的黄金分割法程序设计实验报告.doc
  9. HALCON 21.11:深度学习笔记---网络和训练过程(4)
  10. UI-148xLE-M相机参数