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

大兴做网站公司企业网站搭建及优化

大兴做网站公司,企业网站搭建及优化,设计网站的目的,wordpress前台登录窗口做题思路 数列分段 Section IIhttps://www.luogu.com.cn/problem/P1182正如题目所说,我们需要得到一个最小的最大段的值,可能有人将注意力放在分段上,事实上,我们更多的应该关注结果。这是一道二分答案的题,你可以先确…

做题思路

数列分段 Section IIhttps://www.luogu.com.cn/problem/P1182正如题目所说,我们需要得到一个最小的最大段的值,可能有人将注意力放在分段上,事实上,我们更多的应该关注结果。这是一道二分答案的题,你可以先确认某次分段后的可能的最大段的值q,然后尽量往最大段的值方向去分段,这样,在保证了分段后的最大段的值小于等于q,再看所分的段数,如果大于限定的段数,说明不可能最大段的值是q。因为在保证所分段的值不超过q的情况下,无法减少段数使其达到要求,这时应该往大于q的范围上去找。如果小于等于限定的段数,说明可能还有更小的q。因为段数小于要求,可以将某段拆成多段来增大段数,这时可能有更小的q符合要求。而这时为了更快的找到q的值,我们可以使用二分查找的方式去找。对于n个数,最小的q就是每个一段分出n段时,n个数中的最大值,最大的q就是只分出1段时,n个数的和。

#include<stdio.h>
#include<stdlib.h>
int check(int max,int *data,int num,int limit_count){int current_sum=0,count=0;for(int i=0;i<num;i++){if(data[i]>max)return 0;if(current_sum+data[i]>max){count++;current_sum=data[i];}else current_sum+=data[i];}count++;return count<=limit_count;
}
int main() {int N, M, max = 0, sum = 0;scanf("%d %d", &N, &M);int *data = (int*)malloc(sizeof(int) * N);for (int i = 0; i < N; i++) {scanf("%d", &data[i]);sum += data[i];if (data[i] > max)max = data[i];}int left=max,right=sum;while(left<right){int mid=(left+right)/2;if(check(mid,data,N,M))right=mid;else left=mid+1;}printf("%d",left);free(data);return 0;
}

书的复制https://www.luogu.com.cn/problem/P1281 这道题的思路和上面的题一模一样,但要注意输出时的条件:行的起始编号应该从小到大排列,如果有多解,则尽可能让前面的人少抄写。

#include<stdio.h>
#include<stdlib.h>
int check(int max,int *data,int num,int limit_count){int current_sum=0,count=0;for(int i=0;i<num;i++){if(data[i]>max)return 0;if(current_sum+data[i]>max){count++;current_sum=data[i];}else current_sum+=data[i];}count++;return count<=limit_count;
}
int main() {int N, M, max = 0, sum = 0;scanf("%d %d", &N, &M);int *data = (int*)malloc(sizeof(int) * N);for (int i = 0; i < N; i++) {scanf("%d", &data[i]);sum += data[i];if (data[i] > max)max = data[i];}int left=max,right=sum;while(left<right){int mid=(left+right)/2;if(check(mid,data,N,M))right=mid;else left=mid+1;}int result[M][2],current_sum=0,count=0;result[0][1]=N,result[M-1][0]=1;for(int i=N;i>0;i--){if(current_sum+data[i-1]>left){result[count++][0]=i+1;result[count][1]=i;current_sum=data[i-1];}else current_sum+=data[i-1];}for(int i=M-1;i>=0;i--){printf("%d %d\n",result[i][0],result[i][1]);}free(data);return 0;
}

文章转载自:

http://JFqgjIZ2.bhkLt.cn
http://np6YOYuv.bhkLt.cn
http://77nRrcpf.bhkLt.cn
http://ZvClXwGv.bhkLt.cn
http://IuIoSBjL.bhkLt.cn
http://vNEHpaZK.bhkLt.cn
http://2U0O3WEX.bhkLt.cn
http://HWBT01rr.bhkLt.cn
http://dBdV3hKY.bhkLt.cn
http://xUop1oWB.bhkLt.cn
http://sgcfQsqj.bhkLt.cn
http://UpnuIdPy.bhkLt.cn
http://ZhFRBH1E.bhkLt.cn
http://PCl49hPP.bhkLt.cn
http://ynuXxl0M.bhkLt.cn
http://W7gll3g2.bhkLt.cn
http://JeZ1ds7n.bhkLt.cn
http://TYaCZTW4.bhkLt.cn
http://fY4fld8o.bhkLt.cn
http://luE2nBSz.bhkLt.cn
http://dW5BRto0.bhkLt.cn
http://a9V0YDGd.bhkLt.cn
http://0qtbKZx2.bhkLt.cn
http://XtKmoMVZ.bhkLt.cn
http://tCqNZp0A.bhkLt.cn
http://KZu9MZVo.bhkLt.cn
http://HYI6Fsir.bhkLt.cn
http://7lC5wH0U.bhkLt.cn
http://5JCMGhOc.bhkLt.cn
http://gJv2jlx9.bhkLt.cn
http://www.dtcms.com/wzjs/718914.html

相关文章:

  • 户外做爰网站缙云网站建设
  • 网站创建的基本流程深圳公司黄页企业名录
  • 苏州专业高端网站建设机构嘉兴企业网站排名优化
  • 投资网站哪个好网站推广策略的控制和效果评价
  • 网站搭建哪家好乐陵网站开发
  • 郑州做网站公司yooker国家补贴软件网站开发政策
  • 水贝做网站公司漳州软件开发公司
  • 微商城网站建设哪家好开发软件难吗
  • 网站建设苏州wordpress 中文版本
  • 网站酷站设置html编辑器
  • 简单的企业网站cms淳安县千岛湖建设集团网站
  • 网站关键词检测小红书推广引流
  • 做女装的网站网页设计入门书
  • 做网站找那个公司网站开发设计中的收获
  • 思源黑体可以做网站logo设计网站排行榜
  • 农业交易平台网站建设婚庆类的模板网站
  • 网站开发交付清单上海网站建设 分类广告
  • 矢量网站动画怎么做短视频seo询盘系统
  • 即墨做网站的我想学制作网站吗
  • 网站删除期查询健身器材 网站模版
  • 注册公司网站怎么做莱芜都市网房产频道
  • 精品课程网站群晖wordpress 映射
  • 什么网站允许搭建徐汇网站制作
  • 做兼职网站有哪些大学生创意产品设计方案
  • 北京主页网站建设西安最好的互联网公司排名
  • 南宁制作网站如何为网站建设内容
  • 不会编程能建网站包头网站开发建设
  • 网站首页排名突然没了网站后台构建
  • 济宁网站建设费用网络工程师中级职称报考条件
  • 全国做网站的公html5响应式网站建设平台