fork download
  1. import java.math.BigInteger;
  2. import java.util.Scanner;
  3.  
  4. class Main {
  5. public static BigInteger reverse(BigInteger num){
  6. return new BigInteger(new StringBuilder(num+"").reverse().toString());
  7. }
  8. public static void main(String[] args) {
  9. System.out.println("Дай мне число, больше ста!");
  10. Scanner in = new Scanner(System.in);
  11. BigInteger bi = in.nextBigInteger();
  12. byte cont = 0;
  13. do {
  14. BigInteger rev = reverse (bi);
  15. BigInteger sum = bi.add(rev);
  16. int x = sum.toString().length();
  17. if (x % 2 == 0){
  18. int half = x / 2;
  19. double result = Math.pow(10,half);
  20. int i = (int) result;
  21. //bi = sum % half;
  22. BigInteger bi2 = new BigInteger(Integer.toString(i));
  23. bi = sum.divide(bi2);
  24. System.out.println(bi);
  25. } else {
  26.  
  27. }
  28. cont ++;
  29. } while (cont <1);
  30.  
  31.  
  32. }
  33. }
Success #stdin #stdout 0.07s 2184192KB
stdin
1005
stdout
Дай мне число, больше ста!
60