Advertisement
Ahmed_Negm

D

Apr 14th, 2024
753
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define ll long long
  5. #define nl "\n"
  6.  
  7. void files(){
  8.     ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
  9.     #ifndef ONLINE_JUDGE
  10.         freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  11.     #endif
  12. }
  13.  
  14.  
  15. void solve(){
  16.     ll a,b,c,d; cin>>a>>b>>c>>d;
  17.     if(a > b) swap(a,b);
  18.  
  19.     ll ans = b/c - (a-1)/c + b/d - (a-1)/d - b/(c*d) + (a-1)/(c*d);
  20.     cout<<b-a+1-ans<<nl;
  21.  
  22. }
  23.  
  24. int main(){
  25.     files();
  26.     int t = 1;
  27.     // cin>>t;
  28.     while(t--) solve();
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement