# Hartals

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
 This problem has been solved by mlc413.

 Sorter: mlc413 Programming Challeneges http://icpcres.ecs.baylor.edu/onlinejudge/index.php?option=com_onlinejudge&page=show_problem&problem=991

Determine the number of work days lost to "Hartals". This website seems to have issues with java, and requires a special heading to run properly in C/C++.

Melanie's C++ solution

```
/*@JUDGE_ID: 00000  10050  c++ */

#include <iostream>
#include <stdio.h>
#include <stdlib.h>

int main();
void doStuff();

int main() {

int T, i;
scanf("%d", &T);
for(i = 0; i < T; i++){
doStuff();
}

return 0;

}

void doStuff(){
int N, P, i, j, p_i, sum;
scanf("%d", &N);
int days[N+1];
scanf("%d", &P);

for(i = 0; i <= N; i++){
days[i] = 0;
}

for(i = 0; i < P; i++){
scanf("%d", &p_i);
for(j = p_i; j <= N; j+=p_i){
days[j] = 1;
}
}

for(i = 6; i <= N; i+=6){
days[i] = 0;
i++;
days[i]=0;
}
sum = 0;
for(i = 1; i <= N; i++){
sum += days[i];
}

printf("%d\n", sum);

}

```