#include<bits/stdc++.h> #define ll long long using namespace std; const int N = 1e3+10; bool check(int x) { int sum = 0,m = x; //分割m,然後計算次方和sum while(m != 0) { int k = m % 10; //取個位 sum += pow(k,4); //累加k的4次方 m /= 10; //去除個位 } return sum == x; //水仙花數判斷條件 } int main() { for(int i = 1000; i <= 9999; i++) if(check(i)) cout << i << " "; return 0; }