Thursday, March 17, 2011

10050 - Hartals


#include<iostream>
#include<cstdlib>
#define M 3700
using namespace std;

bool lost[M];
int main()
{
    register int h,i,j,l,t,n,p;
    //freopen("in.txt","r",stdin);
    scanf("%d",&t);
    while(t--)
    {
        l=0;
        scanf("%d%d",&n,&p);
        for(i=0;i<=n;i++)lost[i]=false;
        for(i=1;i<=p;i++)
        {
            scanf("%d",&h);
            for(j=h;j<=n;j=j+h)
                if(j%7!=0&&j%7!=6)
                    lost[j]=true;
        }
        for(i=1;i<=n;i++)
            if(lost[i])l++;
        printf("%d\n",l);
    }
    exit(0);
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.