1.


/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, WS09
* Problem: 382 Perfection
* Link:
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=5&page=show_problem&problem=318
*
* @author Kratzer Kevin
* @version 1.0, 10/14/2009
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.120
*/


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Scanner;



public class Main382 {

protected final BufferedReader input;
protected final BufferedWriter out;
public Main382() {
input = new BufferedReader(new InputStreamReader(System.in));
out = new BufferedWriter(new OutputStreamWriter(System.out));
}

void process() throws IOException {
out.append("PERFECTION OUTPUT\n");
Scanner s = new Scanner(input);
while(s.hasNextInt()) {
int a = s.nextInt();
if(a == 0) {
break;
}
int result = 0;
for(int c = 2; c <= a; c++) {
for(int b=1; b <= a; b++) {
int cMulB = c*b;
if(cMulB == a) {
result += b;
} else if(cMulB > a) {
break;
}
}
}
String nr = String.valueOf(a);
int curLength = nr.length();
while(curLength < 5) {
out.append(' ');
curLength++;
}
out.append(nr);
if(result == a) {
out.append(" PERFECT\n");
} else if(result > a) {
out.append(" ABUNDANT\n");
} else {
out.append(" DEFICIENT\n");
}

}
out.append("END OF OUTPUT\n");
out.flush();
}



public static void main(String... args) throws Exception {
new Main382().process();
}
}


2.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, WS09
* Problem: 382 Perfection
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=5&page=show_problem&problem=318
*
* @author Christoph Hausmann
* @version 0.1, 10/21/2009
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.120
*/

import java.io.IOException;
import java.util.Scanner;


public class Perfection_382 {

public static void main(String... args) throws IOException {
final Scanner scanner = new Scanner(System.in);


final StringBuffer sb = new StringBuffer();
sb.append("PERFECTION OUTPUT\n");

while(scanner.hasNextInt()) {

final int curNum = scanner.nextInt();

if(curNum == 0)
break;

int curSum = 0;

for(int i = 1; i < curNum; i++) {
if(curNum%i == 0)
curSum += i;
}

for(int i = curNum; i < 10000; i*=10) {
sb.append(" ");
}

sb.append(curNum);
sb.append(" ");

if(curSum < curNum) {
sb.append("DEFICIENT\n");
} else if(curSum > curNum) {
sb.append("ABUNDANT\n");
} else {
sb.append("PERFECT\n");
}

}

sb.append("END OF OUTPUT\n");

System.out.print(sb.toString());
}


private static int[] parseNums(String readLine) {
final String[] split = readLine.split(" ");
final int[] nums = new int[split.length];

for(int i = 0; i < split.length; i++) {
nums[i] = Integer.parseInt(split[i]);
}

return nums;
}
}