因為其輸入是間隔天數,在五六不算所以用set判斷,可以避免重複。
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;
int main(int argc, char const *argv[])
{
int t;
cin >> t;
while (t--)
{
int d, n;
cin >> d >> n;
set<int> streetday;
for (int i = 0; i < n; i++)
{
int x;
cin >> x;
int c = x;
while (x <= d)
{
if (x % 7 != 6 && x % 7 != 0 && streetday.count(x) == 0)
{
streetday.insert(x);
}
x = x + c;
}
}
cout << streetday.size() << endl;
}
return 0;
}