1.

/**
* Angewandte Mathematik, SS11
* Problem: 10018 - Reverse and Add
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=959
*
* @author Markus Schöllner
* @author Andreas Maier
* @version 1.0, 05/28/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.376
*/


import java.util.*;

public class Main {

public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int N;
long number;
long[] palindrome = new long[2];
N = input.nextInt();

while(N > 0){
number = input.nextLong();
palindrome = nextNumber(0,number);

System.out.println(palindrome[0] +" "+palindrome[1]);
N--;
}
}

//errechnet über Rekursion die nächste Zahl und bricht ab falls die zahl ein Palindrom ist
private static long[] nextNumber(int iterations, long number){
long reverse = reverse(number);

if(reverse == number) {
long[] n = new long[2];
n[0] = iterations;
n[1] = number;
return n;
}
else {
return nextNumber((iterations+1), (number+reverse));
}

}
//Berechnet die umgekehrte Version der Zahl
private static long reverse(long number){
long reverse = 0, temp = 0;

while(number > 0){
temp = number%10;
reverse = (reverse*10) + temp;
number /= 10;
}
return reverse;
}
}

----------------------------------------------------------------------------------


1.
/**
 * FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
 * Problem: 10018 - Reverse and Add
 * Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=959
 *
 * @author Evgeni Pavlidis
 * @version 1.0, 06/02/2010
 *
 * Method : Ad hoc
 * Status : Accepted
 * Runtime: 0.356
 */

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

class Main {

    private static boolean isPalindrome(String s)
    {
        for(int i = 0; i < s.length(); i++)
            if(s.charAt(i) != s.charAt(s.length()-i-1))
                return false;
        return true;
    }

    public static void main(String...args) throws Exception
    {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        long n, counter;
        int testCases = Integer.parseInt(reader.readLine());

        for(int c = 0; c < testCases; c++)
        {
            n = Long.parseLong(reader.readLine());
            counter = 0;

            while(!isPalindrome("" + n))
            {
                counter++;
                n = n + Long.parseLong(new StringBuffer(""+n).reverse().toString());
            }

            System.out.println(counter + " " + n);
        }
    }
}