프로그래머스/LV2
[프로그래머스 Lv2, python] - 점 찍기
chyam_eun
2025. 3. 31. 18:19
https://school.programmers.co.kr/learn/courses/30/lessons/140107
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
def solution(k, d):
cnt = 0
res = [i for i in range(0,d+1,k)]
j = len(res) - 1 # 길이
for i in range(len(res)):
while j >= 0 and res[i]**2 + res[j]**2 > d**2: # 인덱스가 0이상, 길이가 d보다 크면
j -= 1 # 앞으로 이동
if j < 0: # 인덱스 벗어나면
break
cnt += j + 1
return cnt