#include<iostream>#include<vector>#include<algorithm>usingnamespace std;// 获取一个数字的所有因子
vector<int>GetDivisors(int x){
vector<int> ans;for(int i =1; i < x; i++){if(x % i ==0){
ans.emplace_back(i);}}sort(ans.begin(), ans.end());return ans;}boolIsPerfectNumber(int x){int sum =0;
vector<int> ans =GetDivisors(x);for(auto c: ans){
sum += c;}return x == sum;}intmain(){for(int i =2; i <=10000; i++){if(IsPerfectNumber(i)){
cout << i <<" ";}}
cout << endl;return0;}