-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInsomaniaCure.java
45 lines (42 loc) · 955 Bytes
/
InsomaniaCure.java
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
// QUESTION LINK: https://codeforces.com/problemset/problem/148/A
import java.util.Scanner;
public class InsomaniaCure {
static int cal(int k, int l, int m,int n, int d) {
int count = 0;
int a[] = new int[d+1];
for (int i = k; i <= d; i = i + k) {
if (a[i] != 1) {
a[i] = 1;
count++;
}
}
for (int i = l; i <= d; i = i + l) {
if (a[i] != 1) {
a[i] = 1;
count++;
}
}
for (int i = m; i <= d; i = i + m) {
if (a[i] != 1) {
a[i] = 1;
count++;
}
}
for (int i = n; i <= d; i = i + n) {
if (a[i] != 1) {
a[i] = 1;
count++;
}
}
return count;
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int k = sc.nextInt();
int l = sc.nextInt();
int m = sc.nextInt();
int n = sc.nextInt();
int d = sc.nextInt();
System.out.println(cal(k, l, m,n, d));
}
}