Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
程序把1的情况忽略了。。。。现在改好了#include<iostream> #include<cstdio> #include<algorithm> #include<cstdlib> using namespace std; int main() { int i,n,num; int flag=0; while(scanf("%d",&num)&&num) { int sum=1; if(num==1) { printf("%5d DEFICIENT\n",num); continue; } n=num/2; for(i=2;i<n;++i) { if(num%i==0) { sum+=i; if(i!=num/i) sum+=num/i; n=num/i; } } if(!flag) printf("PERFECTION OUTPUT\n"); flag=1; printf("%5d ",num); if(sum>num) printf("ABUNDANT\n"); else if(sum==num) printf("PERFECT\n"); else printf("DEFICIENT\n"); } printf("END OF OUTPUT\n"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator