Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define nl "\n"
- void files(){
- ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- void solve(){
- ll a,b,c,d; cin>>a>>b>>c>>d;
- if(a > b) swap(a,b);
- ll ans = b/c - (a-1)/c + b/d - (a-1)/d - b/(c*d) + (a-1)/(c*d);
- cout<<b-a+1-ans<<nl;
- }
- int main(){
- files();
- int t = 1;
- // cin>>t;
- while(t--) solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement