30 lines
445 B
C++
30 lines
445 B
C++
#include <bits/stdc++.h>
|
||
|
||
using namespace std;
|
||
|
||
//是不是水仙花数
|
||
bool isSXH(int n) {
|
||
int s = 0, m;
|
||
m = n;
|
||
while (m) {
|
||
int a = m % 10;
|
||
s += a * a * a;
|
||
m /= 10;
|
||
}
|
||
return s == n;
|
||
}
|
||
/**
|
||
* 测试用例:1000
|
||
输出:
|
||
153
|
||
370
|
||
371
|
||
407
|
||
*/
|
||
int main() {
|
||
int n;
|
||
cin >> n;
|
||
for (int i = 2; i <= n; i++)
|
||
if (isSXH(i)) cout << i << endl;
|
||
return 0;
|
||
} |