[백준: 1920] 수 찾기
"""
시작시간: 02:32
종료시간: 02:41
"""
n = int(input())
arr = list(map(int, input().split()))
m = int(input())
check_arr = list(map(int, input().split()))
arr.sort()
def binary_search(arr, start, end, target):
if start > end:
return None
mid = (start + end) // 2
if arr[mid] == target:
return target
elif arr[mid] > target:
return binary_search(arr, start, mid - 1, target)
else:
return binary_search(arr, mid + 1, end, target)
for i in check_arr:
target = binary_search(arr, 0, n - 1, i)
if target == i:
print(1)
else:
print(0)
[백준: 1929] 소수 구하기
"""
시작시간: 03:20
종료시간: 03:42
"""
m, n = map(int, input().split())
def check_prime(num):
root = int(num ** (1 / 2))
for i in range(2, root + 1):
if num % i == 0:
return False
return True
for i in range(m, n + 1):
if i == 1:
continue
if check_prime(i):
print(i)