
Codeforces
想想阿牛会怎么做
这个作者很懒,什么都没留下…
展开
-
codeforces CF 492 B 二分搜索
分析: 对半径d采用二分搜索,需要注意的是,需要提前对路灯的位置排序。需要对题目注意的是精度问题exp=1e-9.代码: #include<bits/stdc++.h> using namespace std; const int maxn = 1005; const double eE = 1e-9; int a[maxn]; int n, l; int chec...原创 2018-04-17 23:18:19 · 171 阅读 · 0 评论 -
codeforces CF 706 B Interesting drink
分析: 首先考虑暴力算法,对于每个q,如果每次都遍历n,则时间复杂度O(n²),对1<q,n<100000这种数量级来说,取极限值必然超时。 因此采用二分搜索。首先将x数组排序,(二分搜索要保证序列有序)。所以问题转化为,对每次询问q,在商店序列x中二分搜索合适的区间。代码:/* Input 5 3 10 8 6 11 4 ...原创 2018-04-19 08:41:39 · 209 阅读 · 0 评论