Untitled

mail@pastecode.io avatar
unknown
plain_text
23 days ago
590 B
1
Indexable
Never
#include <bits/stdc++.h>
#define maxn 100

using namespace std;

int ucln( int x, int y)
{
    int du;
    while ( y != 0 )
    {
        du = x % y;
        x = y;
        y = du;
    }
    return x;
}

int bcnn(int z, int t)
{
    int a = z; int b = t;
    int k = ucln(z, t);
    return a*b/k;
}

int n, p, q, r;
int main(){


    while ( cin >> n >> p >> q >> r )
    {
        int a = n/ bcnn(p,q);
        int b = n/ bcnn(q,r);
        int c = n/ bcnn(p,r);
        int d = n/ bcnn(p,bcnn(q,r));
        cout << a + b + c - 3*d << endl;
    }


}
Leave a Comment