Workspace
Người dùng duc12345
Từ
Giới thiệu
include <bits/stdc++.h>
using namespace std; long long a,b,k,c,d,q,s; int main() { cin>>a>>b>>k; cin>>c>>d>>q; if(k==q) s=k; else s=k*q;
if(a==c and b==d)
{
cout<<(b/k-(a-1)/k)+(b/q-(a-1)/q)-(b/s-(a-1)/s);
return 0;
}
if(b<c or d<a)
{
cout<<(b/k-(a-1)/k)+(d/q-(c-1)/q);
return 0;
}
if(c<a and b<d)
{
cout<<(b/k-(a-1)/k)+(d/q-(c-1)/q)-(b/(s)-(a-1)/(s));
return 0;
}
if(a<c and d<b)
{
cout<<(b/k-(a-1)/k)+(d/q-(c-1)/q)-(d/(s)-(c-1)/(s));
return 0;
}
if(c <= b && d > b) {
cout << (b/k - (a-1)/k) + (d/q - (c-1)/q) - (b/s - (c-1)/s);
return 0;
}
if(c < a && d >= a) {
cout << (b/k - (a-1)/k) + (d/q - (c-1)/q) - (d/s - (a-1)/s);
return 0;
}
}