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

unsigned long long gcd(unsigned long long x,unsigned long long y)
{
     unsigned long long r=x%y;
     if(r==1||y==1)return 1;
     else if(r<=0)return y;
     return gcd(y,r);
}
unsigned long long lcm(unsigned long long a,unsigned long long b)
{
    return (a/gcd(a,b))*b;
}

int main(void)
{
     int T;
     unsigned long long n,x1,x2,x3,ans=0;
     //unsigned long long d1,d2,d3,d4;
     scanf("%d",&T);
     while(T--)
     {
          scanf("%lld%lld%lld%lld",&n,&x1,&x2,&x3);

          /*d1=gcd(n,x1);
          d2=gcd(n,x2);
          d3=gcd(n,x3);
          d4=gcd(gcd(d1,d2),d3);*/
          ans=n/lcm(lcm(gcd(n,x1),gcd(n,x2)),gcd(n,x3));

          printf("%lld\n",ans);

     }
     return 0;

}
close fullscreen
Login or Register to edit or fork this paste. It's free.