andy6804tw
8/14/2016 - 2:58 AM

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=&problem=318&mosmsg=Submission+received+wit

import java.util.*;  
  
public class Main {  
  
    public static void main(String[] args) {  
        Scanner scn = new Scanner(System.in);  
        System.out.println("PERFECTION OUTPUT");
        while(scn.hasNext()){
        	int num=scn.nextInt(),tot=0;
        	if(num==0){
        		System.out.println("END OF OUTPUT");
        		break;
        	}
        	for(int i=1;i<num;i++){
        		if(num%i==0)
        			tot+=i;
        	}
        	if(tot==num)
        		System.out.printf("%5d  PERFECT\n",tot);
        	else if(tot>num)
        		System.out.printf("%5d  ABUNDANT\n",num);
        	else if(tot<num)
        		System.out.printf("%5d  DEFICIENT\n",num);
        }
    }
    /* 
    題目:Q382: Perfection
    作者:1010
    時間:西元 2016 年 8 月 */
}