python 변수 참조
조회수 615회
case = int(input())
TM = 1000*1000*10
factors = [0] * (TM + 1)
def getFactorsBrute(hi):
for div in range(1, hi+1):
multiple = div
while multiple <= hi:
factors[multiple] += 1
multiple += div
return 0
for i in range(case):
n, lo, hi = map(int, input().strip().split(' '))
getFactorsBrute(hi)
cnt = 0
for i in range(lo, hi+1):
if factors[i] == n:
cnt += 1
print(cnt)
factors[] 를 외부에 선언하고 getFactorsBrute에서 factors[] 를 사용합니다. 첫 번째 for문을 case 만큼 반복하면서 factors를 사용하는데 어떻게 매번 초기화 해주지 않아도 원하는 factors를 얻을 수 있는건지 궁금합니다.
-
(•́ ✖ •̀)
알 수 없는 사용자
댓글 입력