Hartals
原文链接 http://huiming.io/2013/04/28/hartals.html
注:以下为加速网络访问所做的原文缓存,经过重新格式化,可能存在格式方面的问题,或偶有遗漏信息,请以原文为准。
<!--more-->
#include <iostream>
#include <vector>
using namespace std;
void hartal(vector<bool> & days, int h) {
int n = days.size();
int t = h - 1;
while (t < n) {
int r = t % 7;
if (r != 5 && r != 6)
days[t] = true;
t += h;
}
}
int main() {
int t;
if (cin >> t) {
for (int i = 0; i < t; i++) {
int n, p;
vector<bool> days;
cin >> n >> p;
days.resize(n, false);
for (int j = 0; j < p; j++) {
int h;
cin >> h;
hartal(days, h);
}
int count = 0;
for (int j = 0; j < n; j++) {
if (days[j])
count++;
}
cout << count << endl;
}
}
return 0;
}