fork(1) download
  1. import java.util.Scanner;
  2.  
  3. class PALIN
  4. {
  5. public static int reverse(int n)
  6. {
  7. int reversed = 0;
  8. while (n > 0)
  9. {
  10. reversed = 10*reversed + n % 10;
  11. n = n/10;
  12. }
  13. return reversed;
  14. }
  15.  
  16. public static boolean isPalindrome(int n)
  17. {
  18. return (n==reverse(n));
  19. }
  20.  
  21. public static void main(String[] args)
  22. {
  23. Scanner sc = new Scanner(System.in);
  24. int t = sc.nextInt();
  25.  
  26. for (int i=0;i<t; i++)
  27. {
  28. int n = sc.nextInt();
  29. for (int nxt=n+1;nxt<=1000000;nxt++)
  30. {
  31. if (isPalindrome(nxt)){
  32. System.out.println(nxt);
  33. break;
  34. }
  35. }
  36. }
  37. }
  38. }
Success #stdin #stdout 0.1s 212864KB
stdin
2
808
2133
stdout
818
2222