Skip to content

Commit 6514105

Browse files
committed
[23.01.23/Python] 수 찾기
1 parent 1c005d9 commit 6514105

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Python_BOJ_2023/1920.py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# 수 찾기
2+
3+
n = int(input())
4+
arr1 = list(map(int, input().split()))
5+
arr1.sort()
6+
7+
m = int(input())
8+
arr2 = list(map(int, input().split()))
9+
10+
def binary_search(num):
11+
global arr1
12+
start = 0
13+
end = len(arr1) - 1
14+
15+
while start <= end:
16+
mid = (start + end) // 2
17+
if arr1[mid] == num:
18+
return True
19+
20+
if arr1[mid] < num:
21+
start = mid + 1
22+
elif arr1[mid] > num:
23+
end = mid - 1
24+
25+
return False
26+
27+
28+
for i in arr2:
29+
if binary_search(i):
30+
print(1)
31+
else:
32+
print(0)

0 commit comments

Comments
 (0)