注意:
(1)特殊情况即原数可开跟时
(2)减少循环次数,约数一定是成对出现的
include[HTML_REMOVED]
include[HTML_REMOVED]
using namespace std;
int main()
{
int n,a,i,j,s;
scanf(“%d”,&n);
for(j=1;j<=n;j)
{
scanf(“%d”,&a);
s=0;
for(i=1;i*i<a;i)
{
if(a%i==0)
{
if(i<a);
s=s+i;
if(i!=a/i&a/i<a)
s=s+a/i;
}
}
if(a==s)
printf(“%d is perfect\n”,a);
else
printf(“%d is not perfect\n”,a);
}
return 0;
}