以下代码是使用枚举算法,找出所有各位数字的立方和等于该数本身的三位数。
for num in range(100, 1000): hundreds = num // 100 tens = (num // 10) % 10 units = num % 10 if hundreds**3 + tens**3 + units**3 == num: print(num)
正确
错误