728x90
반응형
이분 탐색 문제이다. 이분 탐색 안쓰고 그냥 반복문 돌려서 풀면 시간 초과가 나온다.
n = int(input())
s, e = 0, int((2**63)**0.5)+1
res = 0
while s <= e:
m = (s+e)//2
if m**2 >= n:
res = m
e = m-1
else:
s = m+1
print(res)
728x90
반응형
'Agorithm > 백준 알고리즘' 카테고리의 다른 글
백준 알고리즘 2776번 암기왕(python) (2) | 2021.02.26 |
---|---|
백준 알고리즘 2428번 표절(python) (2) | 2021.02.26 |
백준 알고리즘 2343번 기타 레슨(python) (0) | 2021.02.26 |
백준 알고리즘 2022번 사다리(python) (0) | 2021.02.26 |
백준 알고리즘 1590번 캠프가는 영식(python) (0) | 2021.02.26 |