二分查找
文章平均质量分 64
Charon_HN
NLP炼丹儿
展开
-
三分入门HihoCoder - 1142+HDU2899
三分·三分求极值.描述这一次我们就简单一点了,题目在此:在直角坐标系中有一条抛物线y=ax^2+bx+c和一个点P(x,y),求点P到抛物线的最短距离d。提示:三分法在之前的几周中我们了解到二分法作为分治中最常见的方法,适用于单调函数,逼近求解某点的值。但当函数是凸形函数时,二分法就无法适用,这时就需要用到三分法。从三分法的名字中我们可以猜到,三分法是对于需要逼近的区间做三等分:...原创 2019-01-13 21:59:03 · 348 阅读 · 0 评论 -
牛客 矩阵 二维哈希+二分
题目链接题意给出一个n * m的矩阵。让你从中发现一个最大的正方形。使得这样子的正方形在矩阵中出现了至少两次。输出最大正方形的边长。分析这题关键点就是如何去定义正方形,如果纯粹去暴力,将矩阵逐行去分析,那么复杂度将会到达O(n3 ),如果知道二维哈希,那么获得正方形的哈希值就可以在O(1)的时间复杂度下得到了。二维哈希的关键就是要定义和获取,定义如下:for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) hasha[i][j]原创 2021-04-09 12:16:34 · 211 阅读 · 0 评论 -
HihoCoder - 1053 居民迁移(二分)
题目链接公元2411年,人类开始在地球以外的行星建立居住点。在第1326号殖民星上,N个居住点分布在一条直线上。为了方便描述,我们设第i个居住点的位置是Xi,其中居住着Yi位居民。随着冬季的到来,一些人口较多的居住点的生态循环系统已经开始超负荷运转。为了顺利度过严冬,殖民星上的居民一致同意通过转移到人口较少的居住点来减轻人口众多的居住点的负荷。遗憾的是,1326殖民星的环境非常恶劣。在冬季到来前,每个居民点的居民最远能迁移到距离不超过R的居民点。1326殖民星的居民希望知道,如何安排迁移才能使完成迁移后原创 2021-02-23 16:26:15 · 102 阅读 · 0 评论 -
2019 蓝桥杯省赛 A 组模拟赛(一)计蒜客 A2229
题目链接:https://vjudge.net/problem/%E8%AE%A1%E8%92%9C%E5%AE%A2-A2229某班有 nn 个同学,每个同学有一个外向程度 a_iai 。由于要进行某个活动,需要把他们分成若干个小组,每个小组的人数至少为 mm 人。不同外向程度的人在一个小组会产生不开心值,定义一个小组的不开心值为组内成员外向程度最大值和最小值的差,一个班级的不开心值为...原创 2020-02-19 23:09:34 · 868 阅读 · 0 评论 -
POJ 3484 二分前缀和
Data-mining huge data sets can be a painful and long lasting process if we are not aware of tiny patterns existing within those data sets.One reputable company has recently discovered a tiny bug in ...原创 2018-11-05 12:24:35 · 181 阅读 · 0 评论 -
HDU 4614 二分区间端点实现线段树区间查询
Vases and Flowers Alice is so popular that she can receive many flowers everyday. She has N vases numbered from 0 to N-1. When she receive some flowers, she will try to put them in the vases, one f...原创 2018-12-01 19:06:27 · 144 阅读 · 0 评论 -
UVA714 二分最小化最大值+贪心处理输出
Copying BooksTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld &amp;amp; %lluSubmitStatusDescriptionBefore the invention of book-printing, it was very hard to make a copy of a book. ...原创 2019-01-14 14:01:00 · 190 阅读 · 0 评论 -
Largest Allowed Area (前缀和+二分)
题目描述A company is looking for land to build its headquarters. It has a lot of money and can buy as many land patches as it needs. Its goal, however, is finding the largest square region containing no ...原创 2019-04-29 17:52:01 · 266 阅读 · 0 评论 -
2019牛客暑期多校训练营(第六场)D Move 二分
链接:https://ac.nowcoder.com/acm/contest/886/D来源:牛客网题目描述After the struggle of graduating from college, TangTang is about to move from a student apartment to his new home.TangTang has n items to move...原创 2019-08-06 11:20:56 · 281 阅读 · 0 评论 -
2019牛客暑期多校训练营(第九场) H Cutting Bamboos 二分+主席树
题目链接输入:5 43 5 1 7 42 4 3 51 4 4 91 3 1999 1011112 2 1 1输出:2.1000000052154062.6296296380460264.8220668546855450.000000026077032题意:有n棵竹子,然后你需要用y次去砍完这些竹子,但是你每次砍下来的竹子的长度和是相同的,问第x砍竹子的时候是在...原创 2019-08-21 10:27:27 · 389 阅读 · 0 评论 -
POJ 3662
Telephone LinesFarmer John wants to set up a telephone line at his farm. Unfortunately, the phone company is uncooperative, so he needs to pay for some of the cables required to connect his farm to ...原创 2018-11-04 16:00:15 · 159 阅读 · 0 评论 -
POJ 3685 二分套二分求解
Given a N × N matrix A, whose element in the i-th row and j-th column Aij is an number that equals i2 + 100000 × i + j2 - 100000 × j + i × j, you are to find the M-th smallest element in the matrix....原创 2018-10-26 18:51:43 · 246 阅读 · 0 评论 -
POJ 2976 二分之最大化平均值问题
In a certain course, you take n tests. If you get ai out of bi questions correct on test i, your cumulative average is defined to be.Given your test scores and a positive integer k, determine how ...原创 2018-10-24 08:47:05 · 210 阅读 · 0 评论 -
poj2456 贪心+二分
Farmer John has built a new long barn, with N (2 <= N <= 100,000) stalls. The stalls are located along a straight line at positions x1,...,xN (0 <= xi <= 1,000,000,000).His C (2 <= C &l...原创 2018-05-29 17:12:51 · 157 阅读 · 0 评论 -
poj 3273(二分找最小值里面最大的数)最大化最小值
Farmer John is an astounding accounting wizard and has realized he might run out of money to run the farm. He has already calculated and recorded the exact amount of money (1 ≤ moneyi ≤ 10,000) that h...原创 2018-05-31 15:37:24 · 256 阅读 · 0 评论 -
HDU 2236 二分+二分图匹配
HDU 无题II在不同的行和列里,是将行和列看做成连个没有交集的集合,这里可以看成是二分图的匹配要求是将最大值与最小值的差值最小化,那就是通过二分进行枚举,不断地缩减它的上界与下界#include <iostream>#include <string>#include <cstdio>#include <algorithm>#...原创 2018-08-23 19:15:59 · 139 阅读 · 0 评论 -
POJ 3104 二分 坑
It is very hard to wash and especially to dry clothes in winter. But Jane is a very smart girl. She is not afraid of this boring process. Jane has decided to use a radiator to make drying faster. But ...原创 2018-10-19 21:35:03 · 414 阅读 · 0 评论 -
POJ 3045 数学证明贪心解决 OR 二分
Farmer John's N (1 <= N <= 50,000) cows (numbered 1..N) are planning to run away and join the circus. Their hoofed feet prevent them from tightrope walking and swinging from the trapeze (and the...原创 2018-10-20 17:31:52 · 303 阅读 · 1 评论 -
POJ 3111 二分解决最大化平均值问题AND高效牛顿迭代法
Demy has n jewels. Each of her jewels has some value vi and weight wi.Since her husband John got broke after recent financial crises, Demy has decided to sell some jewels. She has decided that she w...原创 2018-10-25 15:08:51 · 197 阅读 · 0 评论 -
POJ 3579 双重二分搜索:求列数X计算∣Xi – Xj∣组成新数列的中位数
Given N numbers, X1, X2, ... , XN, let us calculate the difference of every pair of numbers: ∣Xi - Xj∣ (1 ≤ i < j ≤ N). We can get C(N,2) differences through this work, and now your task is to find th...原创 2018-10-25 18:20:49 · 843 阅读 · 0 评论 -
2016 EC-Final Problem D. Ice Cream Tower(二分+贪心)
题目链接题意:这是2016 ACM-ICPC China-Final的D题,一共有N个冰淇淋球,做一个冰淇淋需要K个球,并且由于稳定性,这K个球还必须满足上下相邻的下面比上面大至少两倍。先给出N个球的质量,问最多能做出多少个冰淇淋?分析:可以这样来分析,先将所有的数据a数组从小到大排一下序,然后再枚举所有的情况,每次二分能够组成的塔的个数mid,然后将排完序的数列的前mid个取到另一个b数...原创 2018-10-21 17:49:17 · 333 阅读 · 0 评论 -
转载二分 01 分数规划即最大化平均值的证明&&0/1分数规划、最优比率生成树、最优比率环
首页 新随笔 联系 管理 订阅随笔- 20 文章- 0 评论- 9 [Algorithm]01分数规划——Update:2012年7月27日【关键字】0/1分数规划、最优比率生成树、最优比率环 【背景】 根据楼教主的回忆录,他曾经在某一场比赛中秒掉了一道最优比率生成树问题,导致很多人跟风失败,最终悲剧。自己总结了一些这种问题的解法,因为水平有限,如果有错误或是...转载 2018-10-23 19:33:26 · 204 阅读 · 0 评论 -
poj 1064 最小二分法
Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to organize the most honest contest ever. It was decided to co...原创 2018-05-29 14:37:08 · 174 阅读 · 0 评论