Untitled
raw download clone
TEXT
views 22
,
size 1405 b
#include <stdio.h>
#define circle 100000002

long long int y[100000000],y2[100000000],y3[100000000];

int main()
{
    int t,ans=0;
    long long int n,x1,x2,x3;

    scanf("%d",&t);

    for(int i=1;i<=t;i++)
    {
        scanf("%lld%lld%lld%lld",&n,&x1,&x2,&x3);

        for(int j=x1;j<=circle;j+=x1)
        {
            if(j>n) j=j%n;
            y[j]++;
            //printf("%d ",y[j]);
            if(y[j]>1)
            {
                y[j]--;
                break;
            }
        }

        for(int j=x2;j<=circle;j+=x2)
        {
            if(j>n)
            {
                j=j%n;
            }
            y[j]++;
            y2[j]++;
            //printf("%d ",y[j]);
            if(y2[j]>1)
            {
                y[j]--;
                break;
            }
        }

        for(int j=x3;j<=circle;j+=x3)
        {
            if(j>n) j=j%n;
            y[j]++;
            y3[j]++;
            //printf("%d ",y[j]);

            if(y3[j]>1)
            {
                y[j]--;
                break;
            }

            if(y[j]==3)
            {
                ans++;
            }

        }

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

        for(int i=0;i<=n;i++)
        {
            y[i]=0;
            y2[i]=0;
            y3[i]=0;
        }
        ans=0;
    }


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