728x90
728x90
# 1λΆν° 10000κΉμ§ μ«μ μ μ₯
num_set = set(range(1, 10001))
# μ
ν λλ²κ° μλ μλ₯Ό μ μ₯
not_self_num= set()
for i in range(1, 10001):
for j in str(i): # μ«μλ₯Ό λ¬Έμμ΄λ‘ λ³ννμ¬ 102μ΄λ©΄ 1, 0, 2λ‘ μ κ·Ό
i += int(j) # d(i) = i + j1 + j2 + j3 + .. = 102 + 1 + 0 + 2
not_self_num.add(i) # μ
ν λλ²κ° μλ μ μ μ₯
# μ
ν λλ²λ§ μλ set = μ 체 μ set - μ
ν λλ²κ° μλ μ set
self_num = num_set - not_self_num
# μ€λ¦μ°¨μμΌλ‘ μ λ ¬ ν μΆλ ₯
for i in sorted(self_num):
print(i)
728x90
λ°μν
'π Algorithm > Solved' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[λ°±μ€] 2789 λΈλμ (νμ΄μ¬3 Python3) (0) | 2020.10.03 |
---|---|
[λ°±μ€] 2941 ν¬λ‘μν°μ μνλ²³ (νμ΄μ¬3 Python3) (0) | 2020.10.02 |
[μκ³ λ¦¬μ¦ λ©μ€] rook (C++, μμ νμ) (0) | 2020.07.09 |
[μκ³ λ¦¬μ¦ μ‘μ€] max of arr (C++, μμ νμ) (0) | 2020.07.09 |
[μκ³ λ¦¬μ¦ μ‘μ€] GCD LCM(μ΅λ곡μ½μ μ΅μ곡배μ) (C++, μμ νμ) (0) | 2020.07.09 |