-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPairsDivisiblebyFive.java
More file actions
34 lines (29 loc) · 956 Bytes
/
PairsDivisiblebyFive.java
File metadata and controls
34 lines (29 loc) · 956 Bytes
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
import java.util.ArrayList;
import java.util.Scanner;
public class PairsDivisiblebyFive {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int M = scanner.nextInt();
int N = scanner.nextInt();
ArrayList<Integer> list1 = new ArrayList<>();
ArrayList<Integer> list2 = new ArrayList<>();
for (int i = 1; i <= M; i++) {
list1.add(i);
}
for (int i = 1; i <= N; i++) {
list2.add(i);
}
int count = 0;
for (int num1 : list1) {
for (int j = 0; j < list2.size(); j++) {
int num2 = list2.get(j);
if ((num1 + num2) % 5 == 0) {
count++;
list2.remove(j);
break;
}
}
}
System.out.println(count);
}
}