
ACM_二分
zzti_lhh
这个作者很懒,什么都没留下…
展开
-
51NOD【1010】只包含因子2 3 5的数(丑数)
题目链接(http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1010)题解:因子只包含2 3 5的数为丑数,求出丑数打表,然后二分查找找到满足条件的数。代码:#include<iostream>#include<stdio.h>#include<algorithm&a原创 2018-10-11 16:28:32 · 147 阅读 · 0 评论 -
51NOD【1105】第K大的数
题目链接题解:对结果进行二分,就是找满足条件的数而不是它的位置。左右边界是数的最大乘积和最小乘积。代码:#include<iostream>#include<stdio.h>#include<algorithm>using namespace std;const int MAX_N=5e4+10;typedef long long LL;LL...原创 2018-10-12 17:29:41 · 230 阅读 · 0 评论 -
OpenJudge 3441:Values whose Sum is 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 following, we assume that all lists have the same size n .原创 2019-03-23 11:11:09 · 362 阅读 · 0 评论 -
OpenJudge 2456:Aggressive cows
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).原创 2019-03-23 11:31:44 · 195 阅读 · 0 评论 -
OpenJu 4134:查找最接近的元素
在一个非降序列中,查找与给定值最接近的元素。输入第一行包含一个整数n,为非降序列长度。1 <= n <= 100000。第二行包含n个整数,为非降序列各元素。所有元素的大小均在0-1,000,000,000之间。原创 2019-03-23 11:54:29 · 868 阅读 · 0 评论 -
OpenJ 4143:和为给定数
给出若干个整数,询问其中是否有一对数的和等于给定的数。输入共三行:第一行是整数n(0 < n <= 100,000),表示有n个整数。第二行是n个整数。整数的范围是在0到10^8之间。第三行是一个整数m(0 <= m <= 2^30),表示需要得到的和。原创 2019-03-23 15:12:48 · 2564 阅读 · 0 评论