
二分查找
文章平均质量分 70
henuzxy
已经成为刷题过千的男人,即将成为cf 1900分的男人。
展开
-
leetcode 1739. 放置盒子 (数学,二分)
放置盒子有一个立方体房间,其长度、宽度和高度都等于 n 个单位。请你在房间里放置 n 个盒子,每个盒子都是一个单位边长的立方体。放置规则如下:你可以把盒子放在地板上的任何地方。如果盒子 x 需要放置在盒子 y 的顶部,那么盒子 y 竖直的四个侧面都 必须 与另一个盒子或墙相邻。给你一个整数 n ,返回接触地面的盒子的 最少 可能数量。示例 1:输入:n = 3输出:3解释:上图是 3 个盒子的摆放位置。这些盒子放在房间的一角,对应左侧位置。示例 2:输入:n = 4输出:3解释.原创 2021-01-26 01:24:23 · 781 阅读 · 3 评论 -
codeforces #412 div2 C Success Rate(二分查找)
C. Success Rate time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are an experienced Codeforces user. Today you found out that during yo原创 2017-05-11 16:49:34 · 474 阅读 · 0 评论 -
基本的二分查找
二分查找有两个库函数lower_bound和upper_bound int a[10] = {0,1,2,2,4,4,4,4,5,6}; int k = (int)(lower_bound(a+1,a+1+9,4) - (a+1)); //返回的是第一次出现4的前一个位置结果是3 int f = (int)(upper_bound(a+1,a+1+9,4) - (a+1))原创 2017-08-09 23:32:01 · 300 阅读 · 0 评论 -
codeforces 535C(二分)
中文翻译如下: 给你两个整数A,B. 给你一个无限长的序列,这个序列的第i个数字为A+(i-1)*B 定义一个”m变态操作”为将不超过m个不同位置上的数字递减1. 现在给你n个询问,每个询问由l,t,m决定. 表示问你是否存在一个r,使得a[l],a[l+1],a[l+2]..a[r]这一段的数字,能在进行不超过t次”m变态操作”的 限制下,全都变成0. (各个询问都是独立的,就是说,原创 2017-11-26 18:58:07 · 398 阅读 · 0 评论 -
UVA - 10341 Solve It (二分)
Solve the equation: p ∗ e −x + q ∗ sin(x) + r ∗ cos(x) + s ∗ tan(x) + t ∗ x 2 + u = 0 where 0 ≤ x ≤ 1. Input Input consists of multiple test cases and terminated by an EOF. Each test case consis...原创 2018-04-05 22:36:49 · 379 阅读 · 0 评论 -
codeforces 1019 A. Elections (枚举或三分)
链接昨天CF的题,没想到自己会做的这么傻逼。。。真菜啊题意:就N个选民,M个政党。已知每个选民原本打算投给的政党,已经收买他们的价格,问你花费最少的价格,使得1号政党的票数最多。思路:直接考虑政党的得票数,使得1号政党高于这个票数,其他政党低于这个票数就行了。(1号政党可以远远高于这个得票数,但其他政党必须低于这个票数)然后从1到N枚举这个票数,维护最小值就行了。只要统计每个政党的...原创 2018-08-13 10:29:39 · 503 阅读 · 0 评论 -
POJ 3155 Hard Life 最大密度子图
John is a Chief Executive Officer at a privately owned medium size company. The owner of the company has decided to make his son Scott a manager in the company. John fears that the owner will ultimate...原创 2018-08-18 18:22:37 · 261 阅读 · 0 评论 -
codeforces 1157 D. N Problems During K Days (二分+构造)
D. N Problems During K Daystime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp has to solve exactly n problems to improve his programming...原创 2019-04-27 15:41:30 · 389 阅读 · 0 评论