File size: 664 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
34
35
36
37
38
#include <cstdio>
#include <iostream>

using namespace std;

int parties[105];

int main()
{
    int tc;

    cin >> tc;
    while( tc-- )
    {
        int N, P;
        cin >> N >> P;
        for(int i=0 ; i<P ; i++) cin >> parties[i];

        int lost_days = 0;
        for(int i=1 ; i<=N ; i++)
        {
            if( i%7==6 || i%7==0 ) continue;
            else
            {
                bool flag = false;
                for(int j=0 ; j<P ; j++)
                    if( i%parties[j]==0 )
                        flag = true;

                if( flag ) lost_days++;
            }
        }

        cout << lost_days << endl;
    }
    return 0;
}