poj 1528(水题)

#include<iostream>
#include<cstdio>
/*
PERFECTION OUTPUT
   15  DEFICIENT
   28  PERFECT
    6  PERFECT
   56  ABUNDANT
60000  ABUNDANT
   22  DEFICIENT
  496  PERFECT
END OF OUTPUT
*/ 
using namespace std;
int main(){
    int i,j,k,a[105],s[105],f[105];
    i = 0;
    while(scanf("%d",&a[i])==1&&a[i]){
        for(s[i]=0,j=1;j<=a[i]/2;j++){
            if(a[i]%j==0){
                s[i] += j;
            }
        }
        if(s[i]==a[i]){
            f[i] = 0;
        }
        else if(s[i]>a[i]){
            f[i] = 1;
        }
        else if(s[i]<a[i]){
            f[i] = -1;
        }
        i++;
    }
    printf("PERFECTION OUTPUT\n");
    for(j=0;j<i;j++){
        printf("%5d  ",a[j]);
        if(f[j]==0){
            printf("PERFECT");
        }
        else if(f[j]==1){
            printf("ABUNDANT");
        }
        else if(f[j]==-1){
            printf("DEFICIENT");
        }
        printf("\n");
    }
    printf("END OF OUTPUT\n");
    return 0;
}

 

上一篇:MVVMLight 中一个 View 对应多的 ViewModel,和一个 View 对应 一个ViewModel


下一篇:10组-Alpha冲刺-3/6