1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, WS10/11
* Problem: 382 Perfection
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=5&page=show_problem&problem=318
*
* @author Fabian Liebl
* @version 1.0, 10/06/2010
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 2.328
*/

import java.io.*;
import java.util.*;

public class Main {

public static void main(String[] args) throws IOException {
//BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in));
Scanner sc = new Scanner(System.in);

int number;
//String[] numbers;
Vector<Integer> properDivisors = new Vector<Integer>();
int addedProperDivisors;

System.out.println("PERFECTION OUTPUT");

//numbers = inputReader.readLine().split(" ");

//for (int n = 0; n < numbers.length; n++) {
while (true) {
//number = Integer.parseInt(numbers[n]);
number = sc.nextInt();

if (number == 0) {
System.out.println("END OF OUTPUT");
return;
}

// Get all proper divisors
properDivisors.clear();
for (int i = 1; i < number; i++) {
for (int j = number; j > 1; j--) {
if (i*j == number) {
properDivisors.add(i);
break;
}
}
}

// Add all proper divisors
addedProperDivisors = 0;
for(Integer i: properDivisors) {
addedProperDivisors += i;
}

if (addedProperDivisors == number) {
System.out.printf("%5d PERFECT\n", number);
} else {
if (addedProperDivisors < number) {
System.out.printf("%5d DEFICIENT\n", number);
} else {
System.out.printf("%5d ABUNDANT\n", number);
}
}
}
}

}


2.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, WS10/11
* Problem: 382 Perfection
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=5&page=show_problem&problem=318
*
* @author Manuel Hager
* @version 1.1, 10/21/2010
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.116
*/

import java.util.Scanner;

public class Main
{
private static StringBuilder outputString = new StringBuilder("PERFECTION OUTPUT\n");

private static void add(int number) {
int sum = calcDivisorSum(number);
String result = "PERFECT";

if(sum != number) {
result = sum > number? "ABUNDANT" : "DEFICIENT";
}

outputString.append(String.format("%5d %s%n", number, result));
}

private static int calcDivisorSum(int value) {
int sum = 1;

int sqrt = (int)Math.sqrt(value);

for(int i = 2; i <= sqrt; i++) {
if(value % i == 0) {
sum += i;
sum += (value / i);
}
}

return sqrt * sqrt == value? sum - sqrt : sum ;
}

private static void print() {
outputString.append("END OF OUTPUT");
System.out.println(outputString.toString());
}

public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);

for(int number = scanner.nextInt(); number != 0; number = scanner.nextInt()) {
add(number);
}
print();

scanner.close();
}
}



3.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 382 Perfection
* Link: http://uva.onlinejudge.org/external/3/382.pdf
*
* @author Robert Reichart
* @version 1.0, 19/03/2010
*
* Status : Accepted
* Runtime: 0.104
*/

import java.io.*;
import java.util.*;

class Main {
//Main Methode
public static void main(String[] args){
//Einlesen der Werte aus der Eingabe
Scanner in = new Scanner(System.in);
//erstellen einer Ausgabe
PrintWriter out = new PrintWriter(System.out);
//Array fuer Maximale anzahl an werten
Integer[] werte = new Integer[100];
//uebertragen der werte aus dem Scanner in den Array
for(int i = 0; in.hasNext(); i++){
werte[i] = in.nextInt();
}

//Ausgabe des Einleitungs Outputs
out.println("PERFECTION OUTPUT");
//Testen jedes Wertes und ausgabe des entsprechenden Ergebnisses
for(int i = 0; i < werte.length && werte[i] != 0; i++){
int sum = divsum(werte[i]);
if(sum == werte[i]){
out.printf("%5d PERFECT%n", werte[i]);
}else if(sum < werte[i]){
out.printf("%5d DEFICIENT%n", werte[i]);
} else {
out.printf("%5d ABUNDANT%n", werte[i]);
}
}
//Ausgabe des End outputs
out.println("END OF OUTPUT");
out.close();

}

//Methode um die Summe aller Teiler einer Zahl zu berechnen
static int divsum(int zahl){
//berechnung aller Teiler von n und bilden deren sSumme
int sum = 0;
int n = zahl/2;
//schleife um alle in frage kommenden werte durchzutesten
for(int i = 1; i <= n; i++){
//wenn i ein teiler von n ist zu sum hinzuaddieren und ausgeben
if(zahl%i == 0){
sum += i;
}
}
return sum;
}
}

4.


 

/**

* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10

* Problem: 382 Perfection

* Link: http://uva.onlinejudge.org/external/3/382.pdf

*

* @author Viktoriya Ryabova

* @version 1.0, 04/21/2010

*

* Method : Ad-Hoc

* Status : accepted

* Runtime: 0.144

*/

 

import java.util.Scanner;

public class Main {

/**

* @param args

*/

public static void main(String[] args) {

Scanner sc = new Scanner (System.in);

int eingabe []= new int[100];

//werte in array einlesen

for(int i=0; sc.hasNext(); i++){

eingabe[i] = sc.nextInt();

if(i==0) System.out.println("PERFECTION OUTPUT");

if (eingabe[i]!=0){

//vergleichen die summe mit dem wert selbst

if(eingabe[i]==countSum(eingabe[i]))System.out.println((printFormat(eingabe[i]))+ eingabe[i] +" PERFECT");

else if (eingabe[i]>countSum(eingabe[i]))System.out.println((printFormat(eingabe[i]))+ eingabe[i] +" DEFICIENT");

else System.out.println((printFormat(eingabe[i]))+ eingabe[i] +" ABUNDANT");

}

else {

System.out.println("END OF OUTPUT");

}

}

}

 

private static int countSum (int number){

int sum=0;

for (int i=1; i<=number/2;i++){

if(number%i==0){

sum+=i;

}

}

return sum;

}

public static String printFormat(int number){

String spaceCount = String.valueOf(number);

String str="";

for (int i=1; i<6-spaceCount.length(); i++){

str += " ";

}

return str;

}

}


5.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 382 Perfection
* Link: http://uva.onlinejudge.org/external/3/382.pdf
*
* @author M. Lambeck / M. Haus
* @version 1.0, 10/06/2010
*
* Status : Accepted
* Runtime:
*/

import java.util.Scanner;

public class Main
{
static int next = 0;
static boolean intro = true;


public static void main (String[] args)
{
Scanner st = new Scanner(System.in);


while(true)
{
int num = st.nextInt();

if (num == 0)
break;

doit(num);
}


System.out.println("END OF OUTPUT");
}


private static void doit(int num)
{

if (intro)
{
System.out.println("PERFECTION OUTPUT");
intro = false;
}


if (num == 1)
{
System.out.printf("%5d  DEFICIENT%n",num);
return;
}


int tmp = (int) (Math.sqrt(num) + 0.001);
int sum = 1;


while (tmp > 1)
{


if (num % tmp == 0)
{
sum += tmp;
sum += (num / tmp);


}
tmp--;
}



if (sum >= num)
{
if (sum == num)
{
System.out.printf("%5d  PERFECT%n", num);


} else
{
System.out.printf("%5d  ABUNDANT%n",num);
}
} else
{
System.out.printf("%5d  DEFICIENT%n",num);
}


}
}