-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy path10050.cpp
More file actions
executable file
·55 lines (43 loc) · 1.07 KB
/
10050.cpp
File metadata and controls
executable file
·55 lines (43 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* Problem: Hartals UVa 10050 PC 110203
Programmer: Md. Mahmud Ahsan
Compiled: Visual C++ 6.0
Date: 04-09-04
*/
#include <iostream>
#include <vector>
using namespace std;
int main(){
vector <bool> days(3655); // store days
int i, j, count; // count store the total hartals
int t, n, parties;
// n = number of days
int averDay; // days of hartals by each party
cin >> t; // test case
for (int test = 0; test < t; test++){
count = 0;
// initialize all to false
for (i = 0; i < days.size(); i++)
days[i] = false;
cin >> n >> parties;
for (j = 0; j < parties; j++){
// each parties hartals declared
cin >> averDay;
// i = averDay - 1 as array index starts with 0
for (i = averDay - 1; i < n; i += averDay){
days[i] = true;
}
}
// for friday and saturday
days[5] = days[6] = false;
for (i = 5; i < n; i += 7){
days[i] = false;
days[i + 1] = false;
}
for (i = 0; i < n; i++){
if (days[i] != false)
count++;
}
cout << count << endl;
}
return 0;
}