---
# System prepended metadata

title: UVA 10050 Hartals

---

# UVA 10050 Hartals
##  題目連結 [UVA 10050](https://vjudge.net/problem/UVA-10050)
### 題目內容
A social research organization has determined a simple set of parameters to simulate the behavior of the political parties of our country. One of the parameters is a positive integer h (called the hartal parameter) that denotes the average number of days between two successive hartals (strikes) called by the corresponding party. Though the parameter is far too simple to be flawless, it can still be used to forecast the damages caused by hartals. The following example will give you a clear idea:

Consider three political parties. Assume h~1~ = 3, h~2~ = 4 and h~3~ = 8 where hi is the hartal parameter for party i (i = 1, 2, 3). Now, we will simulate the behavior of these three parties for N = 14 days. One must always start the simulation on a Sunday and assume that there will be no hartals on weekly holidays (on Fridays and Saturdays).

The simulation above shows that there will be exactly 5 hartals (on days 3, 4, 8, 9 and 12) in 14 days. There will be no hartal on day 6 since it is a Friday. Hence we lose 5 working days in 2 weeks. In this problem, given the hartal parameters for several political parties and the value of N, your job is to determine the number of working days we lose in those N days.
### 輸入限制
The first line of the input consists of a single integer T giving the number of test cases to follow. The first line of each test case contains an integer N (7 ≤ N ≤ 3650) giving the number of days over which the simulation must be run. The next line contains another integer P (1 ≤ P ≤ 100) representing the number of political parties in this case. The ith of the next P lines contains a positive integer hi (which will never be a multiple of 7) giving the hartal parameter for party i (1 ≤ i ≤ P).
### 輸出限制
For each test case in the input output the number of working days we lose. Each output must be on a separate line.
### 解題思路
1.禮拜五和禮拜六不能算、第一天是禮拜日
2.輸入第一個是case數，第二個是天數，第三個是有幾個party
3.要輸出總共有幾天
### 程式碼
```cpp=
#include<bits/stdc++.h>
using namespace std;
int a[105];
int main(){
    int kase;
    cin>>kase;
    while(kase--){
        memset(a,0,sizeof a);
        long long n,p,cot=0;
        cin>>n;
        cin>>p;
        for(int i=0;i<p;i++){
            cin>>a[i];
        }
        for(int i=1;i<=n;i++){
            for(int j=0;j<p;j++){
                if(i%a[j]==0){
                    if(i%7!=0 && i%7!=6){
                        cot++;
                        break;
                    }
                }
            }
        }
        cout<<cot<<endl;
    }
}
```
## 測資
### Sample input
2
14
3
3
4
8
100
4
12
15
25
40
### Sample output
5
15
##  中文題目連結 [zerojudge e579](https://zerojudge.tw/ShowProblem?problemid=e579)