![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
二分搜索
obsorb_knowledge
心有不甘,呼唤着我
展开
-
4 Values whose Sum is 0 poj-2785(四个长度为4000的数组,从每个数组中取出一个数,使取出的四个数和为0 二分优化)
The 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 the followin...原创 2018-04-09 22:02:02 · 366 阅读 · 0 评论 -
Sumsets POJ - 2549 (从 一个 1000数中,找出四个数,满足 a + b = d -c,且求的d最大)
Given S, a set of integers, find the largest d such that a + b + c = d where a, b, c, and d are distinct elements of S.InputSeveral S, each consisting of a line containing an integer 1 <= n <= 1...原创 2018-04-13 18:05:04 · 266 阅读 · 0 评论 -
Boxes and Balls UVALive - 7500 (找规律,二分搜索)
题目链接:点击打开链接题意:你手里有N个球,现在需要用你手里尽可能多的球使得这个游戏经过多次游戏后形成一种恒定状态,恒定状态:最后形成一种恒定状态的情况是每个盒子里放得球数一定是个连续的序列,1 1,2 1,2,3 1,2,3,4.... 思路:经分析:找一个小于等于n的 等差序列前 k 项和,这个等差序列从 a1 = 1 d = 1 n>=(k*(k+1))/2;二分枚举k,即可...原创 2018-04-17 09:23:14 · 118 阅读 · 0 评论 -
UVA - 10341 Solve It (高精度 二分法解方程)
题目链接:点击打开链接题意 找一个0 到 1之间的数使得方程满足,若没有输出 No solution;题解:首先方程根据给出的 数 的范围可知:方程为单调递减,这样就可以运用二分解方程了代码:#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; #include...原创 2017-12-17 09:44:38 · 235 阅读 · 0 评论 -
第十四届华中科技大学程序设计竞赛 K Walking in the Forest()
It’s universally acknowledged that there’re innumerable trees in the campus of HUST.Now you're going to walk through a large forest. There is a path consisting of N stones winding its way to the other...原创 2018-05-01 15:36:33 · 224 阅读 · 0 评论 -
一维战舰 51Nod - 1521 (set 二分查找,判断撒谎)
爱丽丝和鲍博喜欢玩一维战舰的游戏。他们在一行有n个方格的纸上玩这个游戏(也就是1×n的表格)。在游戏开始的时候,爱丽丝放k个战舰在这个表格中,并不把具体位置告诉鲍博。每一只战舰的形状是 1×a 的长方形(也就是说,战舰会占据a个连续的方格)。这些战舰不能相互重叠,也不能相接触。然后鲍博会做一系列的点名。当他点到某个格子的时候,爱丽丝会告诉他那个格子是否被某只战舰占据。如果是,就说hit,否则就说m...原创 2018-05-13 16:09:58 · 248 阅读 · 0 评论 -
Now Loading!!! ZOJ - 4029 (二分+前缀和+思维)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4029 DreamGrid has integers . DreamGrid also has queries, and each time he would like to know the value of for a given number , wh...原创 2018-05-15 09:59:22 · 171 阅读 · 0 评论