You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
445 B

2 years ago
#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;
}