1. 

/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem #640 (Self-Numbers)
* http://icpcres.ecs.baylor.edu/onlinejudge/index.php?option=com_onlinejudge&Itemid=8&category=8&page=show_problem&problem=581
* Watch out: The task is wrong. All self-numbers <=1.000.000 have to be found. Not just 10.000
*
* @author Christian Posselt
* @author Jonathan Schubert
* @version 1.0, 04/05/2009
*
* Status : Accepted
* Runtime: 0.520
*/

import java.lang.StringBuilder;

class Main {

/**
* Checksum - Calculation of the checksum of a number
*
* @param n: an integer value giving the number.
* @return an integer being the checksum of n
*/
public static int checksum(int n){
int num = n;
int checksum = 0;
while (num>0){
checksum += num%10;
num /= 10;
}

return checksum;
}

public static void main(String[] args) {

//setting up all needed variables
StringBuilder answer = new StringBuilder();
int[] self_numbers = new int[1000001];

//initializing the array, saying every number is a self-number
for(int i=1;i<1000001;i++)
self_numbers[i-1] = i;

//removing non-self-numbers
for(int i=1;i<1000001;i++)
{
int sequence = i + checksum(i);
if(sequence<1000001)
self_numbers[sequence-1] = 0;
}

//printing all self-numbers
for(int i=0;i<self_numbers.length;i++)
if(self_numbers[i]!=0)
answer.append(self_numbers[i] + "\n");

System.out.print(answer.toString());

}

}