当前位置: 首页 > news >正文

北京建设电工证查询网站电商网站怎样优化

北京建设电工证查询网站,电商网站怎样优化,响应式网站缺点,网络营销就是网站营销题目来源#xff1a;http://poj.org/problem?id1033 题目大意#xff1a; 某操作系统的文件系统中#xff0c;所有的磁盘空间被分为N个大小相等的cluster#xff0c;编号1至N。每个文件占用一个或多个cluster。所有没有被文件占用的cluster称为是空闲的。磁盘上的一个文件…题目来源http://poj.org/problem?id1033 题目大意   某操作系统的文件系统中所有的磁盘空间被分为N个大小相等的cluster编号1至N。每个文件占用一个或多个cluster。所有没有被文件占用的cluster称为是空闲的。磁盘上的一个文件如果放置在连续的cluster上读取速度是最快的。   磁盘以匀速旋转磁头找到某一个cluster的时间的不等的。因此找到靠近开头的cluster更快。所有的文件被事先按访问频率高到低编号1到K最好的文件放置方式是文件1放置于cluster 1,2,...S1文件2放置于cluster S11, S12,...S1S2.后面类似紧挨着放置。Si表示第i个文件占据的cluster数。   为了将磁盘上的文件整理成上述的最优放置方式需要对cluster进行移动。一次移动包括将一个cluster的内容读出来写至一块空闲的cluster上完成后之前的那块cluster变为空闲。   程序的目标是将磁盘上的文件变为最优放置方式需要的最少移动次数和移动次序。 输入第一行含两个整数N和K分别代表cluster数和文件数。接下来K行每行代表一个文件第一个数字代表该文件含多少cluster后面的每个数字代表所占的cluster的编号。 输出按顺序输出表示移动的数据对Pj,Qj。表示将Pj号cluster的数据移动到Qj.答案可能不唯一采用了Special Judge只要答案正确即可不需要移动则输出No optimization needed. Sample Input 20 3 4 2 3 11 12 1 7 3 18 5 10 Sample Output 2 1 3 2 11 3 12 4 18 6 10 8 5 20 7 5 20 7 实际上可以把问题看过一个数组的重新排列问题.用clusters[N]数组表示第i块cluster处放置的文件块的序号块的序号按重排后结果编排即该块最终应该位于哪一个cluster。那么重排后的结果应该是前面部分的clusters[i]i后面的部分clusters[i]0. 比如sample中的例子 初始状态   i:      1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18 clusters[i]:  0  1  2  0  7  0  5  0  0   8    3    4    0    0   0    0    0    6    重排后   i:      1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18 clusters[i]:  1  2  3  4  5  5  6  8  0   0    0    0    0    0   0    0    0    0  遍历所有的cluster会有以下几种情况 1. clusters[i]0不必处理。 2. clusters[i]1不必处理。 3. 不是以上两种情况则需要移动cluster。此时又有两种情况   a.需要移动的cluster形成链例如      i   1  2  3  4  5  6         clusters[i] 5  0  4  2  3  0     1被5占5被3占3被4占4被2占2为空。用栈保存占用关系借助一个空位逆向移动即可。   b.需要移动的cluster形成环例如         i  1  2  3  4  5  6          clusters 5  1  4  2  3  0    1被5占5被3占3被4占4被2占2又被1占。这种情况从磁盘末尾开始找一个空cluster(题目保证了一个至少有一个空的cluster否则就移动不了了)借助这个空的cluster然后逆向移动。   遍历完成时磁盘整理也完成了。 1 //2 // POJ1033 Defragment3 // Memory: 408K Time: 829MS4 // Language: C Result: Accepted5 //6 7 #include iostream8 #include stack9 10 using namespace std; 11 12 int main() { 13 int N; 14 int K; 15 int move_cnt 0; 16 cin N K; 17 18 int * clusters new int[N 1]; 19 for (int i 0; i N; i) { 20 clusters[i] 0; 21 } 22 int sum 0; 23 for (int i 0; i K; i) { 24 int n; 25 cin n; 26 for (int j 1; j n; j) { 27 int a; 28 cin a; 29 clusters[a] sum; 30 } 31 } 32 for (int i 1; i N; i) { 33 if (clusters[i] 0 || clusters[i] i) { 34 continue; 35 } 36 stackint s; 37 int next clusters[i]; 38 s.push(i); 39 bool isCircle false; 40 while (true) { 41 if (clusters[next] i) { 42 isCircle true; 43 break; 44 } else if (clusters[next] 0) { 45 break; 46 } 47 s.push(next); 48 next clusters[next]; 49 } 50 if (isCircle true) { 51 int j N; 52 while (clusters[j] ! 0) { 53 --j; 54 continue; 55 } 56 cout next j endl; 57 clusters[j] clusters[next]; 58 int t; 59 while (!s.empty()) { 60 t s.top(); 61 cout t next endl; 62 clusters[next] clusters[t]; 63 next t; 64 s.pop(); 65 move_cnt; 66 } 67 clusters[next] clusters[j]; 68 clusters[j] 0; 69 cout j next endl; 70 } else { 71 int t; 72 while (!s.empty()) { 73 t s.top(); 74 cout t next endl; 75 clusters[next] clusters[t]; 76 next t; 77 s.pop(); 78 move_cnt; 79 } 80 clusters[next] 0; 81 } 82 } 83 if (move_cnt 0) { 84 cout No optimization needed endl; 85 } 86 system(pause); 87 return 0; 88 } View Code转载于:https://www.cnblogs.com/dengeven/p/3230223.html
http://www.zqtcl.cn/news/71657/

相关文章:

  • 南京网站制作步骤怎么制作私人网站教程
  • 企业整站推广中国建设银行官网站安装k宝
  • 个人建站网站建立网站方法
  • 建设部科研申报网站用着不好网站的后台建设
  • 公司网站未备案wordpress后台登陆太慢
  • 国内网站为什么要备案网站排名查询系统
  • 河北网站制作 网站开发个人网站带后台源码
  • 建网站用什么服务器好将自己做的网站发布到
  • 庆阳网站建设推广网站如何实现qq登录功能
  • 网站文字代码广点通推广登录入口
  • 外国优秀设计网站WordPress主题中文主题
  • 网站建设的含盖哪方面网站优化要用什么软件
  • 做足球推荐网站能赚钱吗天河网站建设哪个好
  • 网站关键词建设厦门企业网站建设方案
  • 做淘客的网站有哪些如何做网站给女朋友
  • 移动网站开发教程下载pk10网站怎么做
  • 顺德做网站设计的公司销售技巧
  • 网站做二维码网页制作基础教程第2版答案
  • 苏州网站开发找哪家wordpress主题检测
  • 摄影网站开发深圳易百讯网站建设公司
  • 微信小程序网站制作网站rar文件
  • 保险网站建设公司百度搜索引擎原理
  • wordpress的vps建站流程北京装修公司口碑
  • php网站开发程序员做企业网站时需要注意哪些地方
  • 新手做啥网站好公司网址平台有哪些
  • 辽宁网站建设招标大连长建个人主页
  • 中小型教育网站的开发与建设打开网站是空白页面
  • 网站标题用什么隔开百度官网推广
  • 珠海网站建设专线工业和信息化部电子第五研究所
  • 网站标题应怎设置网站设计过程