lower ceil none http cout bits c++ alt mes
12/3
CF895B 二分
- #include < bits / stdc++.h > using namespace std;
- const int N = 1e5 + 10;
- typedef long long LL;
- LL a[N];
- int main() {
- ios: :sync_with_stdio(false);
- LL n,
- x,
- k,
- ans = 0;
- cin >> n >> x >> k;
- for (int i = 0; i < n; i++) cin >> a[i];
- sort(a, a + n);
- for (int i = 0; i < n; i++) {
- LL tmp = (LL)(ceil(1.0 * a[i] / x) * x);
- ans += lower_bound(a, a + n, tmp + k * x) - lower_bound(a, a + n, max(a[i], (k - 1) * x + tmp));
- }
- cout << ans << endl;
- return 0;
- }
CF做题记录
来源: http://www.bubuko.com/infodetail-2415702.html