P2678 跳石头
题解:二分枚举答最长的最短跳跃距离。本题关键在于函数怎么写。我们可以这样想,如果当前石头与上一块石头的距离小于枚举的答案,那么说明当前石头需要被移走,依次反复,如果到达终点的时候所移走的石头不超过块,那么说明当前枚举的答案可行,但是需要继续增加距离,因为可能还不是最长的,否则就减小距离。
代码
题解:二分枚举答最长的最短跳跃距离。本题关键在于函数怎么写。我们可以这样想,如果当前石头与上一块石头的距离小于枚举的答案,那么说明当前石头需要被移走,依次反复,如果到达终点的时候所移走的石头不超过块,那么说明当前枚举的答案可行,但是需要继续增加距离,因为可能还不是最长的,否则就减小距离。
P1577 切绳子题解:因为精度问题,所以我们将其转换成整数,然后二分枚举KKK条绳子的最长长度。只要注意当枚
P1824 进击的奶牛题解:二分枚举最大的最近距离。关键在于check函数的写法,首先可以确定第
P1883 函数题解:容易发现F(x)F(x)F(x)是一个凹函数,因此可以利用三分来
题目:https://www.luogu.org/problemnew/show/P2678 不要以为是做过的那个题。想一想就有了。
分治 二分答案
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M