#include<bits/stdc++.h>
using namespace std;
int main()
{
int n, m, i, j, t, k, l, o;
cin >> l;
for(o=1; o<=l; o++)
{
cin >> n >> m;
int a[n+1] = {0};
for(i=1; i<=m; i++)
{
cin >> t;
for(j=t; j<=n; j+=t)
{
a[j] = 1;
}
}
j = 6;
int j1 = 0;
while(j<=n)
{
if(j+j1 > n)
break;
a[j+j1] = 0;
j += 6;
j1++;
}
k = 7;
while(k<=n)
{
if(k>n)
break;
a[k] = 0;
k += 7;
}
int c = 0;
for(i=1; i<=n; i++)
{
if(a[i] == 1)
c++;
}
cout << c << endl;
}
return 0;
}
Comments
Post a Comment