~cpp // no10050 - Hartals #include <iostream.h> #define MAX_CASE 100 int main() { int nCase; int Save_Result[MAX_CASE]; int n = 0; int i, j; int count = 0; int nDays; int nPoliticalparty; bool *Days; int *HartalParameter; cin >> nCase; // 입력 while (n < nCase) { cin >> nDays; cin >> nPoliticalparty; Days = new bool[nDays]; HartalParameter = new int[nPoliticalparty]; for (i=0 ; i<nPoliticalparty ; i++) cin >> HartalParameter[i]; // 계산 for (i=0 ; i<nPoliticalparty ; i++) { j=HartalParameter[i]; while (j <= nDays) { if ((j-1)%7 == 5 || (j-1)%7 == 6 || Days[j-1] == true) count--; Days[j-1] = true; j += HartalParameter[i]; count++; } } Save_Result[n++]=count; count = 0; } for (i=0 ; i<n ; i++) cout << Save_Result[i] << endl; delete [] HartalParameter; delete [] Days; return 0; }