您的位置:首页 > 其它

POJ-1528

2015-09-12 18:30 260 查看
#include<iostream>
#include<stdio.h>
using namespace std;

int calc(int n){
if(n==1){
return 0;
}

int sum=1;

for(int i=2;i<n;i++){
if(1.0*n/i-n/i==0){
sum+=i;
}
}

return sum;
}

int main(int argc, char *argv[]){
cout<<"PERFECTION OUTPUT"<<endl;
int n;
while(cin>>n,n){
if(n>calc(n)){
//cout<<n<<" DEFICIENT"<<endl;
printf("%5d  DEFICIENT\n",n);
}else if(n<calc(n)){
//cout<<n<<" ABUNDANT"<<endl;
printf("%5d  ABUNDANT\n",n);
}else{
//cout<<n<<" PERFECT"<<endl;
printf("%5d  PERFECT\n",n);
}

}
cout<<"END OF OUTPUT"<<endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: