#include <iostream>
using namespace std;
int f(int n)
{
}
int main()
{
int n ;
cin >> n;
for(int i = 100 ; i <= n; i ++)
{
int res = 0;
int x = i;
while(x) //会从个位开始逐位处理
{
int t = x % 10;
res += (t * t * t);
x /= 10;
}
if(res == i) cout << res <<" ";
}
return 0;
}
输出所有的水仙花数字。水仙花数字是指一个三位数字,其各个位的立方和等于其本身。例如153 = 1^3 +5^3+3^ 3。
于 2024-03-16 09:37:24 首次发布