Skip to content

Commit dedc8cc

Browse files
committed
1 parent a1eb36d commit dedc8cc

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Hongjoo/lv1/이진수정렬.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# n ,k = int(input().split()) # 개수, 특정 정수 위치
2+
# array = list(map(int,input().split()))
3+
def binary(num):
4+
tmp = ""
5+
while num !=0 :
6+
if num % 2 == 0 :
7+
tmp= "0"+tmp
8+
num = num // 2
9+
else :
10+
tmp = "1" + tmp
11+
num = num // 2
12+
return tmp
13+
14+
15+
n ,k = map(int,input().split()) # 개수, 특정 정수 위치
16+
array = list(map(int,input().split()))
17+
18+
bcount_o = []
19+
for o in array :
20+
l=binary(o).count("1")
21+
bcount_o.append([l,o])
22+
23+
# 내림차순 정렬
24+
bcount_o.sort(reverse= True)
25+
print(bcount_o[k-1][1])
26+

0 commit comments

Comments
 (0)