算法基础--二分
# 算法基础--二分
pxlsdz
冲就完了!
展开
-
牛客挑战赛33 C 艾伦的立体机动装置(几何体的最短距离 三分)
OJ题号牛客挑战赛33 C 艾伦的立体机动装置https://ac.nowcoder.com/acm/contest/1115/C简单题意中文题正解思路因为下表面是可以走的,所以不能直接算s点和t点展开的直线距离。 枚举经过下表面的每一条边,再在每条边上三分求出最短距离。注意最短距离的初始值要设为不经过下表面任何一条边的最短距离。slen记录每个顶点到s点的...原创 2019-10-24 15:32:18 · 660 阅读 · 0 评论 -
POJ 1505 (Copying Books)(经典二分)
DescriptionBefore the invention of book-printing, it was very hard to make a copy of a book. All the contents had to be re-written by hand by so called scribers. The scriber had been given a book an...原创 2019-02-14 01:23:57 · 427 阅读 · 0 评论 -
POJ - 2018 Best Cow Fences (二分 长度>=l的子序列最大和+前缀和)
Best Cow FencesTime Limit: 1000MS Memory Limit: 30000K Total Submissions: 14467 Accepted: 4664 DescriptionFarmer John's farm consists of a long row of N (1 <= N <= 100,00...原创 2019-02-12 18:51:42 · 357 阅读 · 1 评论 -
CF-394D Physical Education and Buns
D. Physical Education and Bunstime limit per test 2 secondsmemory limit per test 256 megabytesinput standard inputoutput standard outputThe Physical education teacher at SESC is a sort of mathema...原创 2019-02-12 16:07:04 · 267 阅读 · 0 评论 -
poj 1064 Cable master 【二分 + 精度控制】
Cable masterTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 29552 Accepted: 6246DescriptionInhabitants of the Wonderland have decided to hold a regional programming c...原创 2019-02-12 02:33:45 · 151 阅读 · 0 评论 -
POJ1905-Expanding Rods 二分+数学
Expanding RodsTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 13780 Accepted: 3563DescriptionWhen a thin rod of length L is heated n degrees, it expands to a new length ...原创 2019-02-12 00:09:20 · 182 阅读 · 0 评论 -
poj 2456 Aggressive cows (最小值最大化二分问题)
Aggressive cowsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 11952 Accepted: 5842DescriptionFarmer John has built a new long barn, with N (2 <= N <= 100,000) sta...原创 2019-02-11 23:12:08 · 237 阅读 · 0 评论 -
poj 2785 4 Values whose Sum is 0 二分问题
DescriptionThe SUM problem can be formulated as follows: given four lists A, B, C, D of integer values, compute how many quadruplet (a, b, c, d ) ∈ A x B x C x D are such that a + b + c + d = 0 . In...原创 2019-02-11 21:17:59 · 238 阅读 · 0 评论 -
POJ 3579 Median 二分
MedianTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 3699 Accepted: 1056DescriptionGiven N numbers, X1, X2, ... , XN, let us calculate the difference of every pair of n...原创 2019-02-11 19:08:16 · 255 阅读 · 0 评论 -
51NOD 1278 相离的圆(二分 + 排序 好题)
平面上有N个圆,他们的圆心都在X轴上,给出所有圆的圆心和半径,求有多少对圆是相离的。例如:4个圆分别位于1, 2, 3, 4的位置,半径分别为1, 1, 2, 1,那么{1, 2}, {1, 3} {2, 3} {2, 4} {3, 4}这5对都有交点,只有{1, 4}是相离的。收起输入第1行:一个数N,表示圆的数量(1 <= N <= 50000)第2 - N ...原创 2019-04-18 23:32:32 · 241 阅读 · 0 评论 -
2018ICPC青岛区域赛 zoj4062 Plants vs. Zombies(二分+贪心)
BaoBao and DreamGrid are playing the gamePlants vs. Zombies. In the game, DreamGrid grows plants to defend his garden against BaoBao's zombies.Plants vs. Zombies(?)(Image from pixiv. ID: 21790160;...原创 2019-05-05 08:51:49 · 285 阅读 · 0 评论 -
AtCoder Regular Contest 070 D - No Need(二分+bitset或者背包+思维)
D - No NeedTime Limit: 2 sec / Memory Limit: 256 MBScore :600600pointsProblem StatementAtCoDeer the deer hasNNcards with positive integers written on them. The number on theii-th card...原创 2019-06-02 16:49:35 · 566 阅读 · 0 评论 -
2019 Multi-University Training Contest 1 D.Vacation 二分或者思维
VacationTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 3015Accepted Submission(s): 1404Special JudgeProblem DescriptionTom and ...原创 2019-09-21 22:09:49 · 549 阅读 · 0 评论 -
51nod 2482 小b学进制 二分/或者卡
2482 小b学进制2.0 秒 262,144.0 KB 20 分 3级题小b最近在学习进制转化。对于一个10进制整数n和一个数k,她能快速求出k进制下的n。如果k进制下的n所有数位都是1,即形如11111111,那么小b就会觉得开心。现在给定n,请你求出最小的k使得k进制下的n能让小b开心。收起输入输入一个十进制整数,表示n(没有前导0)...原创 2019-08-12 20:17:39 · 311 阅读 · 0 评论 -
CodeForces 253E Printer 二分+模拟
E. Printertime limit per test4 secondsmemory limit per test256 megabytesinputinput.txtoutputoutput.txtLet's consider a network printer that functions like that. It starts working at ...原创 2019-08-16 09:29:27 · 298 阅读 · 0 评论 -
CodeForces - 248D. Sweets for Everyone!
For he knew every Who down in Whoville beneath, Was busy now, hanging a mistletoe wreath. "And they're hanging their stockings!" he snarled with a sneer, "Tomorrow is Christmas! It's practically here!...原创 2019-08-10 08:53:39 · 184 阅读 · 0 评论 -
CodeForces - 240 C. Practice 模拟或者二分或者规律
Little time is left before Berland annual football championship. Therefore the coach of team "Losewille Rangers" decided to resume the practice, that were indefinitely interrupted for uncertain reason...原创 2019-08-01 10:50:19 · 156 阅读 · 0 评论 -
51nod 1267 4个数和为0
1267 4个数和为01.0 秒 131,072.0 KB 20 分 3级题给出N个整数,你来判断一下是否能够选出4个数,他们的和为0,可以则输出"Yes",否则输出"No"。收起输入第1行,1个数N,N为数组的长度(4 <= N <= 1000)第2 - N + 1行:A[i](-10^9 <= A[i] <= 10^9)...原创 2019-08-03 15:31:00 · 99 阅读 · 0 评论 -
51nod 1105 第K大的数 思维二分/二分套二分
1105 第K大的数1.0 秒 131,072.0 KB 20 分 3级题数组A和数组B,里面都有n个整数。数组C共有n^2个整数,分别是:A[0] * B[0],A[0] * B[1] ...... A[0]* B[n-1]A[1] * B[0],A[1] * B[1] ......A[1]* B[n-1]......A[n - 1] ...原创 2019-07-24 12:05:22 · 192 阅读 · 0 评论 -
【算法竞赛进阶指南】最佳牛围栏 POJ 2018 Best Cow Fences (二分+贪心)
农夫约翰的农场由NN块田地组成,每块地里都有一定数量的牛,其数量不会少于1头,也不会超过2000头。约翰希望用围栏将一部分连续的田地围起来,并使得围起来的区域内每块地包含的牛的数量的平均值达到最大。围起区域内至少需要包含FF块地,其中FF会在输入中给出。在给定条件下,计算围起区域内每块地包含的牛的数量的平均值可能的最大值是多少。输入格式第一行输入整数NN和FF...原创 2019-07-05 00:38:03 · 712 阅读 · 0 评论 -
HDU5178:pairs(二分法 & 尺取法)
pairsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2497 Accepted Submission(s): 930Problem DescriptionJohn has points on the X ax...原创 2019-02-16 23:33:52 · 343 阅读 · 0 评论 -
HDU 2141 Can you find it?(二分)
Give you three sequences of numbers A, B, C, then we give you a number X. Now you need to calculate if you can find the three numbers Ai, Bj, Ck, which satisfy the formula Ai+Bj+Ck = X. InputThere...原创 2019-02-16 22:39:20 · 115 阅读 · 0 评论 -
二分经典 POJ 3273(最大值的最小化)
POJ 3273题目描述:¢ 给定一个数列,要求把数列切分成m个段,使得总和最大的一段的总和最小。求这个总和。算法分析:二分查找经典例子,总体思路就是我们先假设mid就是我们要找到答案,看它符不符合题目所给要求(分列成m段,最小),具体细节看代码。代码实现:#include <bits/stdc++.h>using namespace std;int main(...原创 2018-02-23 12:23:17 · 405 阅读 · 0 评论 -
二分 poj3258River Hopscotch
poj3258River Hopscotch DescriptionEvery yearthe cows hold an event featuring a peculiar version of hopscotch that involvescarefully jumping from rock to rock in a river. The excitement takes place on ...原创 2018-02-23 00:17:46 · 251 阅读 · 0 评论 -
二分查找算法
二分查找算法¢ 简单定义:在一个单调有序的集合中查找元素,每次将集合分为左右两部分,判断解在哪个部分中并调整集合上下界,重复直到找到目标元素。¢ 时间复杂度:O (logn),优于直接顺序查找O(n)二分查找代码:#include <bits/stdc++.h>using namespace std;int a[10];int main(){ int n; ...原创 2018-02-23 00:16:09 · 179 阅读 · 0 评论 -
二分 HDU Problem G
Problem G Time Limit : 2000/1000ms (Java/Other) Memory Limit :65536/32768K (Java/Other)Total Submission(s) : 7 Accepted Submission(s) : 1Problem DescriptionInhabitants of the Wonderlandhave decide...原创 2018-03-09 13:45:00 · 209 阅读 · 0 评论 -
二分奇葩 HDU Problem H
Problem H Time Limit : 3000/1000ms (Java/Other) Memory Limit :32768/32768K (Java/Other)Total Submission(s) : 1 Accepted Submission(s) : 1Problem DescriptionA有1数m,B来猜.B每猜一次,A就说&quot;太大&quot...原创 2018-03-09 11:28:37 · 229 阅读 · 0 评论 -
三分再三分 HDU Problem F
Problem F Time Limit : 2000/1000ms (Java/Other) Memory Limit :32768/32768K (Java/Other)Total Submission(s) : 6 Accepted Submission(s) : 3Problem DescriptionIn a two-dimensional planethere are two ...原创 2018-03-09 10:54:24 · 231 阅读 · 0 评论 -
二分 hdu problem E
Problem E Time Limit : 3000/1000ms (Java/Other) Memory Limit :32768/32768K (Java/Other)Total Submission(s) : 10 Accepted Submission(s) : 4Problem DescriptionMr. West bought a new car! Sohe is trav...原创 2018-03-08 22:42:44 · 196 阅读 · 0 评论 -
三分加二分 hdu Problem D
Problem D Time Limit : 3000/1000ms (Java/Other) Memory Limit :32768/32768K (Java/Other)Total Submission(s) : 4 Accepted Submission(s) : 3Problem DescriptionThe recreation center of WHUACM Team has...原创 2018-03-08 21:08:52 · 254 阅读 · 0 评论 -
Can you solve this equation?(HDU 2199) 小数二分
Problem DescriptionNow,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,can you find its solution between 0 and 100;Now please try your lucky. InputThe first line of the input conta...原创 2018-03-04 22:57:47 · 327 阅读 · 0 评论 -
HDOJ 2899 Strange fuction 三分或二分
Problem DescriptionNow, here is afuction:<br>&nbsp;&nbsp;F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0&lt;= x &lt;=100)<br>Can you find the minimum value when x isbetween 0 and...原创 2018-03-05 22:22:36 · 255 阅读 · 0 评论 -
POJ 3662/洛谷 P1948 [USACO08JAN]电话线Telephone Lines (SPFA+二分)
RunningTime Limit: 1000MS Memory Limit: 65536K Total Submissions: 7477 Accepted: 2810 DescriptionThe cows are trying to become better athletes, so Bessie isrunning on a track for exactly N (1 ≤...原创 2018-05-29 18:14:21 · 303 阅读 · 0 评论 -
codeforces 609D D. Gadgets for dollars and pounds(二分+贪心)
Gadgets for dollars and pounds 总时间限制: 2000ms 内存限制: 65536kB 描述 一个人手上有s卢布,他要在n天内买m样东西中的k样. 有两种支付方式,每个物品有一种支付方式,要么用美元,要么用英镑。每天有不同的支付方式代价,即换取一美元或英镑,需要付出x[i]卢布的代价。 要求:最早完成买k样东西的天数。如果无法完成任务,输出-1 一种商品只...原创 2019-01-16 22:29:20 · 247 阅读 · 0 评论 -
CodeForces - 626 C. Block Towers 二分
C. Block Towerstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputStudents in a class are making towers of blocks. Each student mak...原创 2019-01-16 20:33:52 · 283 阅读 · 0 评论 -
LightOJ Trailing Zeroes (III) 1138【二分搜索+阶乘分解】
1138 - Trailing Zeroes (III) PDF (English) Statistics ForumTime Limit: 2 second(s) Memory Limit: 32 MBYou task is to find minimal natural number N, so that N! contains exactly Q zeroes ...原创 2019-01-21 19:31:11 · 106 阅读 · 1 评论 -
HDU - 4614 Vases and Flowers 线段树+二分查找
Vases and FlowersTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 5095 Accepted Submission(s): 2109 Problem Description Alice is so p...原创 2019-01-19 02:01:49 · 281 阅读 · 0 评论 -
二分模板
二分,这个模板可以实现,假如可能有g,g+1,g+2,能筛选出最小g代码模板int two(){ ll l=k,r=LNF,mid; while(l<=r) { mid=(l+r)/2; if(cal(mid)>=k) { r=mid-1; } else { l=mid+1; } } printf("%lld\n",l)...原创 2018-08-10 16:16:37 · 203 阅读 · 0 评论 -
POJ 3258 River Hopscotch 二分
River Hopscotch Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 19217 Accepted: 7993 DescriptionEvery year the cows hold an event feat...原创 2018-07-27 14:36:13 · 346 阅读 · 0 评论 -
POJ 3273Monthly Expense每月的费用
题目描述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) ...原创 2018-06-15 22:51:03 · 261 阅读 · 0 评论