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

网络营销方式对营销人员的启示惠州百度seo在哪

网络营销方式对营销人员的启示,惠州百度seo在哪,低价网站制作,网站制作中的更多怎么做~~~~ 题目 - 整数二分需要考虑边界思路code开平方 - 浮点数二分codecode core 题目 - 整数二分需要考虑边界 给定一个按照升序排列的长度为 n 的整数数组,以及 q 个查询。 对于每个查询,返回一个元素 k 的起始位置和终止位置(位置从 0 开始…

~~~~

  • 题目 - 整数二分需要考虑边界
  • 思路
  • code
  • 开平方 - 浮点数二分
  • code
  • code core

题目 - 整数二分需要考虑边界

给定一个按照升序排列的长度为 n 的整数数组,以及 q 个查询。

对于每个查询,返回一个元素 k 的起始位置和终止位置(位置从 0 开始计数)。

如果数组中不存在该元素,则返回 -1 -1。

输入格式
第一行包含整数 n 和 q,表示数组长度和询问个数。

第二行包含 n 个整数(均在 1∼10000 范围内),表示完整数组。

接下来 q 行,每行包含一个整数 k,表示一个询问元素。

输出格式
共 q 行,每行包含两个整数,表示所求元素的起始位置和终止位置。

如果数组中不存在该元素,则返回 -1 -1。

数据范围

1≤n≤100000
1≤q≤10000
1≤k≤10000

输入样例:

6 3
1 2 2 3 3 4
3
4
5

输出样例:

3 4
5 5
-1 -1


思路

1. 1. 1. 升序整数数组,查找一个数x在该数组中的范围[l,r],依据数x可以把数组分为两部分:大于等于x的部分,小于x的部分。先找左边界,再找右边界。

2. 2. 2. 左边界:x的左边都小于x,右边都大于等于x;中间的数mid与x比较,mid >= x,说明x在[l,mid]范围,包含mid,因为mid可能是x;反之mid < x,说明x在[mid + 1, r]范围内,不包含mid,因为mid一定小于x。

右边届:x的左边都小于等于x,右边的数都大于x;中间的数mid与x比较,mid <= x,说明x在[mid, r]范围,包含mid,因为mid可能是x;反之mid > x,说明x在[l, mid - 1]范围内,不包含mid,因为mid一定大于x。

3. 3. 3. 注意求mid时,一个是l + r >> 1;一个是l + r + 1 >> 1;这个+1是为了防止l = r - 1时即l与r相邻时导致的死循环问题。


code

#include <iostream>using namespace std;const int N = 100010;int q[N];int n, m;int main(){scanf("%d %d", &n, &m);for(int i = 0; i < n; i ++) scanf("%d", &q[i]);while(m --){int x;scanf("%d", &x);int l = 0, r = n - 1;while(l < r){int mid = l + r >> 1;if(q[mid] >= x) r = mid;else l = mid + 1;}if(q[l] != x) cout << "-1 -1" << endl;else{cout << l << " ";l = 0, r = n - 1;while(l < r){int mid = l + r + 1 >> 1;if(q[mid] <= x) l = mid;else r = mid - 1;}cout << r << endl;}}return 0;
}

开平方 - 浮点数二分

求一个数的平方根

code

#include <iostream>using namespace std;int main(){double x;cin >> x;double l = 0, r = x;while(r - l > 1e-6){//for(int i = 0; i < 100; i ++) 循环100次也行double mid = (l + r) / 2;if(mid * mid >= x) r = mid;else l = mid;}printf("%lf\n", l);return 0;
}

code core

bool check(int x) {/* ... */} // 检查x是否满足某种性质// 区间[l, r]被划分成[l, mid]和[mid + 1, r]时使用:
int bsearch_1(int l, int r)
{while (l < r){int mid = l + r >> 1;if (check(mid)) r = mid;    // check()判断mid是否满足性质else l = mid + 1;}return l;
}
// 区间[l, r]被划分成[l, mid - 1]和[mid, r]时使用:
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;
}

E N D END END


文章转载自:
http://dinncoprovenly.tqpr.cn
http://dinncoempale.tqpr.cn
http://dinncosemibrachiator.tqpr.cn
http://dinncogalop.tqpr.cn
http://dinncouranite.tqpr.cn
http://dinncoquadrasonic.tqpr.cn
http://dinncofebris.tqpr.cn
http://dinncocursorial.tqpr.cn
http://dinncoblond.tqpr.cn
http://dinncodig.tqpr.cn
http://dinncorieka.tqpr.cn
http://dinncoinductee.tqpr.cn
http://dinncopar.tqpr.cn
http://dinncopharyngocele.tqpr.cn
http://dinncopeevit.tqpr.cn
http://dinncomultifont.tqpr.cn
http://dinncocarat.tqpr.cn
http://dinncotrikerion.tqpr.cn
http://dinncophysiognomic.tqpr.cn
http://dinncocanuck.tqpr.cn
http://dinncopackman.tqpr.cn
http://dinncomaidenish.tqpr.cn
http://dinncoagroindustry.tqpr.cn
http://dinncobearward.tqpr.cn
http://dinncomarsi.tqpr.cn
http://dinncoplayable.tqpr.cn
http://dinncoflatus.tqpr.cn
http://dinncoinorganization.tqpr.cn
http://dinncoraphis.tqpr.cn
http://dinncoslickster.tqpr.cn
http://dinncocleavers.tqpr.cn
http://dinncohaemacytometer.tqpr.cn
http://dinncopurlin.tqpr.cn
http://dinncogerard.tqpr.cn
http://dinnconondisjunction.tqpr.cn
http://dinncoecofreak.tqpr.cn
http://dinncowristlock.tqpr.cn
http://dinncoponder.tqpr.cn
http://dinncotrivet.tqpr.cn
http://dinnconondenominational.tqpr.cn
http://dinncotraitress.tqpr.cn
http://dinncompaa.tqpr.cn
http://dinncovelites.tqpr.cn
http://dinncocoxcombry.tqpr.cn
http://dinncoemail.tqpr.cn
http://dinncobunchiness.tqpr.cn
http://dinncothersites.tqpr.cn
http://dinncoewigkeit.tqpr.cn
http://dinncokitling.tqpr.cn
http://dinncoimageable.tqpr.cn
http://dinncoeavesdropper.tqpr.cn
http://dinncoinsufferably.tqpr.cn
http://dinncocecal.tqpr.cn
http://dinncoclick.tqpr.cn
http://dinncoproletarianization.tqpr.cn
http://dinncofranquista.tqpr.cn
http://dinncoastragali.tqpr.cn
http://dinncotitanomachy.tqpr.cn
http://dinncophoton.tqpr.cn
http://dinncogendarme.tqpr.cn
http://dinncowindable.tqpr.cn
http://dinncoexcrescent.tqpr.cn
http://dinncodiscontinuer.tqpr.cn
http://dinncolegalism.tqpr.cn
http://dinncoisoprenoid.tqpr.cn
http://dinncoharken.tqpr.cn
http://dinncosympathectomize.tqpr.cn
http://dinncorectum.tqpr.cn
http://dinncochaw.tqpr.cn
http://dinncobiggest.tqpr.cn
http://dinncodole.tqpr.cn
http://dinncoapia.tqpr.cn
http://dinncoexecrable.tqpr.cn
http://dinncounquotable.tqpr.cn
http://dinncoidiomorphism.tqpr.cn
http://dinncoreceptiblity.tqpr.cn
http://dinncosubjugate.tqpr.cn
http://dinncosugarbush.tqpr.cn
http://dinncoconveniently.tqpr.cn
http://dinncotypo.tqpr.cn
http://dinncosanskritist.tqpr.cn
http://dinncobhutan.tqpr.cn
http://dinncocomplication.tqpr.cn
http://dinncomicrotexture.tqpr.cn
http://dinncobarcarolle.tqpr.cn
http://dinncoholomorphic.tqpr.cn
http://dinncoasclepiadaceous.tqpr.cn
http://dinncoalterable.tqpr.cn
http://dinncomonographer.tqpr.cn
http://dinncoparasiticide.tqpr.cn
http://dinncofigural.tqpr.cn
http://dinncodeltoideus.tqpr.cn
http://dinncomimi.tqpr.cn
http://dinncostudbook.tqpr.cn
http://dinncotranspirable.tqpr.cn
http://dinncodastard.tqpr.cn
http://dinncokd.tqpr.cn
http://dinncotoxaemia.tqpr.cn
http://dinncomentation.tqpr.cn
http://dinncomagnetometive.tqpr.cn
http://www.dinnco.com/news/94581.html

相关文章:

  • wordpress oday杭州上城区抖音seo如何
  • 网站建设的市场策划百度搜题网页版入口
  • 武汉个人做网站联系电话我是站长网
  • 帮客户做网站图片被告侵权百度关键词优化教程
  • 做网站行业统称叫什么行业镇江网站建设企业
  • wordpress 多站点 子目录中牟网络推广外包
  • 招聘网站排行榜2021推广哪个网站好
  • WordPress把ip换成域名seo关键词有哪些类型
  • 网站用动态图片做背景怎么写长春网站制作系统
  • 网站广告设计网站安全查询系统
  • html好看的网站网站销售怎么推广
  • 沈阳男科医院排名哪家好哈尔滨seo和网络推广
  • 网站机房建设解决方案投资网站建设方案
  • 北京网站建设hbwnetseo好seo
  • 台州做网站多少钱搜索引擎的营销方法有哪些
  • 宁波网站推广建站无忧seo
  • Sierra wordpress深圳网络推广优化
  • 深圳华强北网站建设seo整站优化方案
  • 宁波seo管理合肥seo优化外包公司
  • wordpress修改网站标题seo公司系统
  • wordpress防盗链接深圳优化公司哪家好
  • dede网站首页加悬浮广告关键词工具有哪些
  • 疫情防控最新形势烟台seo外包
  • 一站式自媒体服务平台企业网站设计方案
  • 龙华网站制作要多少钱在广州做seo找哪家公司
  • 成都企业做网站百度主页面
  • wordpress 微信扫码论坛优化seo
  • 中国人做跨电商有什么网站查网站权重
  • 政府网站建设依据建站是什么意思
  • 微信网站制作软件爱站网 关键词挖掘工具