-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCod binar.java
More file actions
33 lines (33 loc) · 925 Bytes
/
Cod binar.java
File metadata and controls
33 lines (33 loc) · 925 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
import java.util.*;
import java.lang.Math;
public class ECCPR{
public static void main(String []args){
int n,nr;
int zero=8,unu=0,max=0;
String aux;
ArrayList<Integer>list=new ArrayList<Integer>();
Scanner sc= new Scanner(System.in);
n=sc.nextInt();
for(int i=0;i<n;i++){
nr=sc.nextInt();
aux=Integer.toBinaryString(nr);
for(int j=0;j<aux.length();j++){
if(aux.charAt(j)=='1'){
unu++;
}
}
zero=8-unu;
if(zero>max){
max=zero;
list.clear();
list.add(nr);
}else if(zero==max){
list.add(nr);
}
unu=0;
}
for(int i=0;i<list.size();i++){
System.out.println(list.get(i));
}
}
}