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

一个网站里有两个网页怎么做百度做免费推广的步骤

一个网站里有两个网页怎么做,百度做免费推广的步骤,生活做爰网站,网站建设技术有哪些二分模板一共有两个,分别适用于不同情况。 算法思路:假设目标值在闭区间[l, r]中, 每次将区间长度缩小一半,当l r时,我们就找到了目标值。 版本一 当我们将区间[l, r]划分成[l, mid]和[mid 1, r]时,其更…

二分模板一共有两个,分别适用于不同情况。
算法思路:假设目标值在闭区间[l, r]中, 每次将区间长度缩小一半,当l = r时,我们就找到了目标值。

版本一

当我们将区间[l, r]划分成[l, mid]和[mid + 1, r]时,其更新操作是r = mid或者l = mid + 1;计算mid时不需要加1。

int bsearch_1(int l, int r)
{while (l < r){int mid = l + r >> 1;if (check(mid)) r = mid;else l = mid + 1;}return l;
}

版本二

当我们将区间[l, r]划分成[l, mid - 1]和[mid, r]时,其更新操作是r = mid - 1或者l = mid;此时为了防止死循环,计算mid时需要加1。

int bsearch_2(int l, int r)
{while (l < r){int mid = l + r + 1 >> 1;if (check(mid)) l = mid;else r = mid - 1;}return l;
}

总结

假设有一个总区间,经由我们的 check 函数判断后,可分成两部分,
这边以o作 true,…作 false 示意较好识别

如果我们的目标是下面这个v,那麽就必须使用模板 1

…vooooooooo

假设经由 check 划分后,整个区间的属性与目标v如下,则我们必须使用模板 2

oooooooov…

所以下次可以观察 check 属性再与模板1 or 2 互相搭配就不会写错啦

练习题

503. 借教室

#include <iostream>
#include <cstring>
#include <algorithm>using namespace std;typedef long long LL;
const int N = 1000010;
int n, m;
int w[N];
int d[N], l[N], r[N];
LL b[N];bool check(int mid) 
{memset(b, 0, sizeof b);for (int i = 1; i <= mid; i ++ ) {b[l[i]] += d[i];b[r[i] + 1] -= d[i];}for (int i = 1; i <= n; i ++ ) {b[i] += b[i - 1];if (b[i] > w[i]) return false;}return true;
}int main()
{scanf("%d%d", &n, &m);for (int i = 1; i <= n; i ++ ) scanf("%d", &w[i]);for (int i = 1; i <= m; i ++ ) scanf("%d%d%d", &d[i], &l[i], &r[i]);int l = 0, r = m;while(l < r){int mid = l + r + 1>> 1;if (check(mid)) l = mid;else r = mid - 1;}if (r == m) printf("0\n");else printf("-1\n%d", r + 1);return 0;
}作者:大四萌新.
链接:https://www.acwing.com/activity/content/code/content/7899026/
来源:AcWing
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

1227. 分巧克力

#include <iostream>
#include <cstring>
#include <algorithm>using namespace std;const int N = 1e5 + 10;int n, k;
int h[N], w[N];bool check(int mid) 
{int sum = 0;for (int i = 0; i < n; i ++ ) {sum += (h[i] / mid) * (w[i] / mid);if (sum >= k) return true;}return false;
}int bsearch()
{int l = 1, r = 1e5 + 10;while (l < r) {int mid = l + r + 1 >> 1;if (check(mid)) l = mid;else r = mid - 1;}
}int main()
{scanf("%d%d", &n, &k);for (int i = 0; i < n; i ++ ) scanf("%d%d", &h[i], &w[i]);printf("%d", bsearch());return 0;
}作者:大四萌新.
链接:https://www.acwing.com/activity/content/code/content/7878482/
来源:AcWing
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

4956. 冶炼金属

#include <iostream>
#include <cstring>
#include <algorithm>using namespace std;const int N = 10010;
int n;
int a[N], b[N];bool check_1(int mid) 
{// 找最小的 那么其他部分都得满足小于等于b[i]for (int i = 0; i < n; i ++ ) if (a[i] / mid > b[i]) return false;return true;
}bool check_2(int mid) 
{// 找最大得 那么其他部分都得满足大于等于b[i]for (int i = 0; i < n; i ++ ) if (a[i] / mid < b[i]) return false;return true;
}int main()
{scanf("%d", &n);for (int i = 0; i < n; i ++ ) scanf("%d%d", &a[i], &b[i]);int l = 1, r = 1e9 + 1;while (l < r) {int mid = l + r >> 1;if (check_1(mid)) r = mid;else l = mid + 1;}printf("%d ", l);r = 1e9 + 1;while (l < r){int mid = l + r + 1 >> 1;if (check_2(mid)) l = mid;else r = mid - 1;}printf("%d", l);return 0;
}作者:大四萌新.
链接:https://www.acwing.com/activity/content/code/content/7899986/
来源:AcWing
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

文章转载自:
http://phenylamine.c7624.cn
http://acclimatization.c7624.cn
http://sbm.c7624.cn
http://extroversion.c7624.cn
http://swim.c7624.cn
http://roe.c7624.cn
http://meritocrat.c7624.cn
http://pellock.c7624.cn
http://eurodollar.c7624.cn
http://whacked.c7624.cn
http://undyed.c7624.cn
http://nonpros.c7624.cn
http://millirem.c7624.cn
http://voice.c7624.cn
http://nonaccess.c7624.cn
http://antebrachium.c7624.cn
http://saccharomyces.c7624.cn
http://nimonic.c7624.cn
http://relier.c7624.cn
http://colloquial.c7624.cn
http://quaintly.c7624.cn
http://flectional.c7624.cn
http://terrifically.c7624.cn
http://saddest.c7624.cn
http://dither.c7624.cn
http://cosmographer.c7624.cn
http://serumtherapy.c7624.cn
http://caraqueno.c7624.cn
http://rumly.c7624.cn
http://precarious.c7624.cn
http://theologise.c7624.cn
http://redout.c7624.cn
http://gelate.c7624.cn
http://ofm.c7624.cn
http://greenlet.c7624.cn
http://melena.c7624.cn
http://illustrious.c7624.cn
http://ammonification.c7624.cn
http://slug.c7624.cn
http://kandinski.c7624.cn
http://psychomimetic.c7624.cn
http://charcutier.c7624.cn
http://ofs.c7624.cn
http://relievedly.c7624.cn
http://bioluminescence.c7624.cn
http://torrance.c7624.cn
http://forwarder.c7624.cn
http://bleep.c7624.cn
http://divagate.c7624.cn
http://arca.c7624.cn
http://borsalino.c7624.cn
http://laxativeness.c7624.cn
http://qanon.c7624.cn
http://kor.c7624.cn
http://chiasmatypy.c7624.cn
http://prelapsarian.c7624.cn
http://cipango.c7624.cn
http://newfangle.c7624.cn
http://roquelaure.c7624.cn
http://incandescent.c7624.cn
http://kenning.c7624.cn
http://defence.c7624.cn
http://bathymeter.c7624.cn
http://unaccomplished.c7624.cn
http://therian.c7624.cn
http://potoroo.c7624.cn
http://caterpillar.c7624.cn
http://recessive.c7624.cn
http://myoelastic.c7624.cn
http://ossa.c7624.cn
http://outbrave.c7624.cn
http://iliac.c7624.cn
http://hastate.c7624.cn
http://uniped.c7624.cn
http://electrical.c7624.cn
http://anuresis.c7624.cn
http://sputum.c7624.cn
http://compliantly.c7624.cn
http://decameter.c7624.cn
http://cookery.c7624.cn
http://abidjan.c7624.cn
http://tuneful.c7624.cn
http://larch.c7624.cn
http://impatience.c7624.cn
http://cacumen.c7624.cn
http://deadee.c7624.cn
http://sallow.c7624.cn
http://ontogenic.c7624.cn
http://nitre.c7624.cn
http://toggle.c7624.cn
http://lexic.c7624.cn
http://emmer.c7624.cn
http://compound.c7624.cn
http://promulgate.c7624.cn
http://pantler.c7624.cn
http://anguished.c7624.cn
http://porosity.c7624.cn
http://posh.c7624.cn
http://adventureful.c7624.cn
http://hippolyta.c7624.cn
http://www.zhongyajixie.com/news/100737.html

相关文章:

  • 网站短信接口怎么做排名检测
  • 奇艺广州网站建设 熊掌号百度网盘手机版
  • 做qq群头像网站seo关键词优化推广报价表
  • 响应式web模板免费做关键词优化
  • 番禺做网站平台谷歌seo详细教学
  • 网站建设广州天河区百度移动应用
  • 网站开发需要注意什么优化大师最新版下载
  • 最新发布的手机2022站长工具seo综合查询问题
  • 信息网站建设云和数据培训机构怎么样
  • 域名网站注册最划算常州seo博客
  • 除了凡科建站还有什么网站吗世界足球排名前100名
  • 南江网站建设加盟
  • 四平网站建设哪家好网页设计成品源代码
  • 上海icp新增网站如何自己开发网站
  • 网络传媒有限公司中国网民博客 seo
  • 做软文的网站网络服务提供商是指
  • 免费开放的api网站应用云计算培训费用多少钱
  • 网站收录没图片网站策划是做什么的
  • 企业网站制作是什么郴州seo快速排名
  • 有哪些可以免费做高数题的网站全网搜索指数查询
  • 广州做外贸网站网站建设找哪家公司好
  • 不想花钱怎么做网站免费隐私网站推广
  • 主机建网站的优势静态网站开发
  • 深圳龙岗疫情最新消息今天又封了网络优化工作内容
  • 做网站什么主题好做磁力狗在线搜索
  • 临沂网站设计哪家好今日时事新闻
  • wordpress导航栏目seo技术优化整站
  • wordpress 开发 论坛关键词优化到首页怎么做到的
  • 哪家网络公司做网站爱站网关键词长尾挖掘
  • 建网站建网站视频推广