题目描述
完全数
样例
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n,x,sum=0;
cin >> n;
for(int i=0;i<n;i++)
{
cin >> x;
if(x==1)
cout << x << " is not perfect" << endl;
else
{
sum+=1;
for(int i2=2;i2<=sqrt(x);i2++)
{
if(x%i2==0)
{
int y=x/i2;
if(y==i2)
sum=sum+i2;
else
sum=sum+i2+x/i2;
}
}
if(sum==x)
cout << x << " is perfect" << endl;
else
cout << x << " is not perfect" << endl;
}
sum=0;
}
return 0;
}