반응형

[백준] 2016번 제곱ㄴㄴ수 - PYTHON

import math

min, max = map(int, input().split())
 
NN = [1] * (max - min + 1) 

tmp_01 = []

for i in range(2, int(math.sqrt(max)) + 1):
    tmp_01.append(i ** 2)


for i in tmp_01:
    j = math.ceil(min / i)
    while i * j <= max:
        NN[i * j - min] = 0
        j += 1

print(sum(NN))
반응형

+ Recent posts