Computer/Coding Test
백준 2018번: 수들의 합 (투 포인터)
안녕도라
2023. 10. 17. 12:58

n = int(input())
count = 1
start_index = 1
end_index = 1
sum = 1
while end_index !=n:
if sum == n:
count +=1
end_index +=1
sum += end_index
elif sum >n:
sum -= start_index
start_index +=1
else:
end_index +=1
sum += end_index
print(count)
오답 이유)
이런 똑똑한 알고리즘이 있다니