Sample Input
2
14
3
3
4
8
100
4
12
15
25
40
Sample Output
5
15
解法: 開表格 只要當日有政黨罷工就記錄
import java.util.Scanner;
public class UVA10050 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int count = sc.nextInt();
for (int i = 0; i < count; i++) {
int size = sc.nextInt();
boolean matrix[] = new boolean[size + 1];
int h_size = sc.nextInt();
for (int j = 0; j < h_size; j++) {
int h = sc.nextInt();
for (int k = 1; k < matrix.length; k++) {
if (k % h == 0 && k % 7 != 0 && k % 7 != 6) {
matrix[k] = true;
}
}
}
int ans = 0;
for (int j = 1; j < matrix.length; j++) {
if (matrix[j] == true)
ans++;
}
System.out.println(ans);
}
sc.close();
}
}