๋ธ๋ก ์ฆ2 : ๋ธ๋ฃจํธํฌ์ค ๋ฌธ์ ์ด๋ค. Code import Foundation func getGenerateNumber(of num: Int) -> Int { var ret = num let num = String(num) num.forEach { ret += Int(numericCast($0.unicodeScalars.first!.value) - 48) } // 0์ ์์คํค์ฝ๋๋ก 48 return ret } func main() { let n = Int(readLine()!)! var result = [Int]() for i in 1...n { if getGenerateNumber(of: i) == n { result.append(i) } } print(result.isEmpty ? 0 : result.min()!) } main() Code2 import sys input = sys.stdin.readline def get_generate_number(num): ret = num num = f"{num}" for char in num: ret += int(char) return ret def main(): n = int(input()) result = [] for i in range(1, n + 1): if get_generate_number(i) == n: result.append(i) print(min(result) if result else 0) if __name__ == "__main__": main() Reference ๋ฐฑ์ค(2231๋ฒ) -๋ถํดํฉ