此题建议使用查表法233333333
include<iostream>
include<vector>
using namespace std;
vector arr = { 6, 28, 496, 8128 };
int main()
{
int n = 0;
while (cin >> n)
{
cout << n << ":";
for (int i = 0; i < arr.size(); i++)
{
if (arr[i] <= n) cout << " " << arr[i];
}
cout << endl;
}
return 0;
}
《NOJ1025 完数》有1个想法