poj1528解题报告

大水题。。。飘过

 

 

 

#include<iostream> #include<cmath> using namespace std; int s(int n) { int i,sum=1; for(i=2;i<=(int)sqrt((double)n);i++) if(n%i==0) sum+=i+n/i; if((int)sqrt((double)n)*(int)sqrt((double)n)==n) sum-=(int)sqrt((double)n); return sum; } int main() { cout<<"PERFECTION OUTPUT"<<endl; int i,j; while(cin>>i&&i) { if(i==1) { printf("%5d DEFICIENT/n",1); continue; } else { j=s(i); if(j>i) printf("%5d ABUNDANT/n",i); else if(j==i) printf("%5d PERFECT/n",i); else printf("%5d DEFICIENT/n",i); } } cout<<"END OF OUTPUT"<<endl; return 0; }

你可能感兴趣的:(poj1528解题报告)