摘要:
二分 P1678 思路 二分先找到>=x的坐标i,然后取a[i]-x,a[i-1]-x的绝对值最小值 代码 #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, m; long long int an 阅读全文
posted @ 2025-08-01 14:53
Roin_Long
阅读(3)
评论(0)
推荐(0)
摘要:
x = x & (x - 1)去除最低位的1 x &= x - 1这个操作会精确地消除x的最低位的1 因此每次执行这个操作时,x中确实有一个1被消除了 所以可以直接count++,因为每次操作都对应一个真实的1 代码 #include <bits/stdc++.h> using namespace 阅读全文
posted @ 2025-08-01 14:33
Roin_Long
阅读(3)
评论(0)
推荐(0)