2018年1月13日 星期六

UVA Q382 - Perfection

#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
int a,b,c,d;
cout<<"PERFECTION OUTPUT"<<endl;
while(cin>>a){
    b=0;
    d=0;
    if(a==0){
        break;
    }
    for(int x=1;x<a;x++){
        if(a%x==0){
        b=b+x;
        }
    }
    c=a;
    while(c>0){
        c=c/10;
        d++;
    }
    for(int x=1;x<=(5-d);x++){
        cout<<" ";
    }
    cout<<a<<"  ";
    if(b==a){
        cout<<"PERFECT";
    }else if(b>a){
        cout<<"ABUNDANT";
    }else{
        cout<<"DEFICIENT";
    }
    cout<<endl;
}
cout<<"END OF OUTPUT"<<endl;

system("pause");
return 0;
}

沒有留言:

張貼留言