Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- int a, b, c, d;
- int main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- cin >> a >> b >> c >> d;
- int res = 0;
- for (int i = 1; i * i <= b; ++i) {
- int l1 = (a - 1) / i + 1, r1 = b / i;
- int l2 = (c - 2 * i - 1) / 2 + 1 , r2 = (d - 2 * i) / 2;
- if (r2 < i || r1 < i) {
- continue;
- }
- l1 = max(l1, i);
- l2 = max(l2, i);
- if ((l1 <= l2 && l2 <= r1) || (l2 <= l1 && l1 <= r2)) {
- res += min(abs(r1 - l2) + 1, abs(r2 - l1) + 1);
- }
- }
- cout << res << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement