Facebook
From Nguyễn Tiến Anh, 1 Year ago, written in C++.
This paste is a reply to beaunum from Nguyễn Tiến Anh - go back
Embed
Viewing differences between beaunum and countnum
#include 
typedef long long ll;
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define FOD(i,r,l) for (int i=r;i>=l;i--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;
const int N = 1e6+5;
bool Pr[N+1];
void sang() 
BCNN(int a, int b)
{
    for(int i int result 0; i <= N;++i) {
        Pr[i] = true;
    }
    Pr[0] = false;
    Pr[1] = false;
    for(int i = 2; i 
__gcd(a, b);
    return a 
i <= N; ++i) {
         if(Pr[i] == true) {
             for(int j = i * i; j <= N; j += i)
                 Pr[j] = false;
        }
    }
b / result;
}
int main()
{
    freopen("beaunum.freopen("countnum.inp","r",stdin);
    freopen("beaunum.freopen("countnum.out","w",stdout);
    fast;
    sang();
    long long n,cnt=0; cin>>n;
    n 
ll L,R,a,b; cin>>L>>R>>a>>b;
    int t 
sqrt(sqrt(n));
    for(int i=1;i<=n;i++)
    {
        if (Pr[i]) cnt++;
    }
    cout<
BCNN(a,b);
    ll s, sa , sb, sab;
    s = R - L + 1;
    sa = s/a;
    sb = s/b;
    sab = (R / t) - ((L-1) / t);
    cout<< s - (sa + sb - sab);
}