Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1.     #include <bits/stdc++.h>
  2.     using namespace std;
  3.     typedef long long ll;
  4.     typedef long double ld;
  5.      
  6.     int a, b, c, d;
  7.      
  8.     int main() {
  9.      
  10.         ios_base::sync_with_stdio(0);
  11.         cin.tie(0);
  12.         cout.tie(0);
  13.     #ifdef _DEBUG
  14.         freopen("input.txt", "r", stdin);
  15.         freopen("output.txt", "w", stdout);
  16.     #endif
  17.      
  18.         cin >> a >> b >> c >> d;
  19.         int res = 0;
  20.         for (int i = 1; i * i <= b; ++i) {
  21.             int l1 = (a - 1) / i + 1, r1 = b / i;
  22.             int l2 = (c - 2 * i - 1) / 2 + 1 , r2 = (d - 2 * i) / 2;
  23.             if (r2 < i || r1 < i) {
  24.                 continue;
  25.             }
  26.             l1 = max(l1, i);
  27.             l2 = max(l2, i);
  28.             if ((l1 <= l2 && l2 <= r1) || (l2 <= l1 && l1 <= r2)) {
  29.                 res += min(abs(r1 - l2) + 1, abs(r2 - l1) + 1);
  30.             }
  31.         }
  32.         cout << res << "\n";
  33.      
  34.         return 0;
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement