Untitled
raw download clone
C
views 22
,
size 518 b
#include <stdio.h>

long long gcd(long long a, long long b)
{
    if (b == 0) return a;
    else return gcd(b, a % b);
}

long long lcm(long long a, long long b)
{
    return a * b / gcd(a, b);
}

int main(void)
{
    int T;
    long long int x1, x2, x3, n, x, y;
    scanf("%d", &T);
    while (T--)
    {
        scanf("%lld%lld%lld%lld", &n, &x1, &x2, &x3);
        x = lcm(gcd(n, x1), gcd(n, x2));
        y = lcm(gcd(n, x3), x);

        printf("%lld\n", n / y);
    }
    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.