-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHartals.java
More file actions
57 lines (44 loc) · 1.28 KB
/
Hartals.java
File metadata and controls
57 lines (44 loc) · 1.28 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
56
57
import java.util.ArrayList;
import java.util.Scanner;
public class Hartals {
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
ArrayList<Integer> hartals = new ArrayList<>();
int cases;
int days;
int parties;
cases = sc.nextInt();
for (int i=0;i<cases;i++)
{
days = sc.nextInt();
parties = sc.nextInt();
while(hartals.size() < parties)
{
int hartal = sc.nextInt();
if((hartal%7) != 0) {
hartals.add(hartal);
}
else {
break;
}
}
int count =0;
int day = 1;
for(int d=1;d<=days;d++) {
if(day == 8)
day =1;
for (int p = 0; p < parties; p++) {
if (d%hartals.get(p)==0 && (day!=6 && day !=7))
{
count++;
break;
}
}
day++;
}
hartals.clear();
System.out.println(count);
}
}
}