py
2025-02-15 14:55:33
发布于:江苏
0阅读
0回复
0点赞
def is_narcissistic_number(n):
# 确保输入是一个三位数
if not (100 <= n <= 999):
return "NO"
# 分解数字并计算立方和
a, b, c = n // 100, (n // 10) % 10, n % 10
return "YES" if a**3 + b**3 + c**3 == n else "NO"
读取输入并输出结果
print(is_narcissistic_number(int(input())))
这里空空如也
有帮助,赞一个