题意:一共n天,给出a1,a2...在它们的倍数日罢工,但是周六周日不罢工,输出n天中罢工的天数
思路:用数组模拟。
//10050 - Hartals
#include <iostream>
#include <cstring>
using namespace std;
bool unwork[3700];
int main()
{
//freopen("data.txt", "r", stdin);
int cases;
scanf("%d", &cases);
while (cases--)
{
int n, p, x, unwork_day = 0;
scanf("%d", &n);
scanf("%d", &p);
for(int i = 0; i < p; i++)
{
scanf("%d", &x);
int s = x;
while(s <= n)
{
if(!unwork[s] && s % 7 != 6 && s % 7 != 0)
{
unwork[s] = true;
unwork_day++;
}
s += x;
}
}
printf("%d\n", unwork_day);
memset(unwork, 0, sizeof(unwork));
}
return 0;
}