-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFourDiv.java
46 lines (32 loc) · 1.02 KB
/
FourDiv.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
46
import java.util.Scanner;
import java.util.*;
public class FourDiv {
public static int ans(int[] arr){
int[] comp = new int[1];
boolean flag = true;
for(int i = 0; i < arr.length; i++){
if(arr[i] % 4 == 0 ) {
if(flag == true) {
comp[0] = arr[i];
flag = false;
}
// System.out.println(comp[0]);
if(comp[0] < arr[i]){
comp[0] = arr[i];
}
}
}
return comp[0];
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// start coding here
int n = scanner.nextInt();
int[] input = new int[n];
for(int i = 0; i < n; i++){
int m = scanner.nextInt();
input[i] = m;
}
System.out.println(ans(input));
}
}