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