Facebook
From Ngo Hoang Dung, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 119
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. long long a, b, c, d,t=0,x,y,k,z;
  4. int main() {
  5.      cin >> a >> b >> c >> d;
  6.     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  7.     freopen("countnum.inp","r",stdin);
  8.     freopen("countnum.out","w",stdout);
  9.      x = b / c - (a - 1) / c;
  10.      y = b / d - (a - 1) / d;
  11.      k = (c * d) / __gcd(c, d);
  12.      z = b / k - (a - 1) / k;
  13.      t= b - a + 1 - x - y + z;
  14.    cout << t;
  15. }
  16.