File size: 623 Bytes
c4b0eef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
    模擬
*/
#include <iostream>
#include <vector>

using namespace std;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    int n_testcase;
    cin >> n_testcase;
    while (n_testcase--) {
        int sum = 0, day, n, m;
        cin >> day >> n;
        vector<bool> calendar(day, false);

        for (int i = 0; i < n; i++) {
            cin >> m;
            for (int j = m - 1; j < day; j += m)
                calendar[j] = true;
        }

        for (int i = 0; i < day; i++)
            if (calendar[i] && i % 7 < 5)
                sum++;

        cout << sum << "\n";
    }
    return 0;
}