fork download
  1. import java.math.BigInteger;
  2. import java.util.Scanner;
  3.  
  4.  
  5. class Ideone {
  6.  
  7. public static void main(String[] args) {
  8.  
  9. int len = 0;
  10. String ausi;
  11. Scanner ip = new Scanner(System.in);
  12. ausi = ip.nextLine();
  13. len = ausi.length();
  14. char[] b = new char[len/2];
  15. char[] a = new char[len/2];
  16.  
  17. System.out.println(ausi +" " + len); /**output the big int just read from stdin + its lenght**/
  18. ausi.getChars(0, len/2, a, 0); /** taking first half of the input big no. **/
  19. if(len % 2 == 0)
  20. {
  21. ausi.getChars(len/2, len-1, a, 0);
  22. //m
  23. }
  24. else
  25. {
  26. ausi.getChars(len/2+1, len, b, 0);
  27. //m = ausi.charAt(len/2);
  28. }
  29. String as = String.valueOf(a); /**in order to convert 'a' to a BIGINT it must b converted to a string first **/
  30. String bs = String.valueOf(b); /** so 'as' and 'bs' are the string representations of 'a' and 'b' resp **/
  31.  
  32. BigInteger A = new BigInteger(as); /**this part throws exception says as should be of form "decimal string"**/
  33. BigInteger B = new BigInteger(bs); /**so whats the diff between a string and a decimal string ??**/
  34.  
  35. if(A.compareTo(B) == 1) // A > B
  36. System.out.println(as+"%"+bs);
  37.  
  38. ip.close();
  39. }
  40. }
Runtime error #stdin #stdout #stderr 0.1s 380800KB
stdin
9876543210
stdout
9876543210 10
stderr
Exception in thread "main" java.lang.NumberFormatException: For input string: ""
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:481)
	at java.math.BigInteger.<init>(BigInteger.java:338)
	at java.math.BigInteger.<init>(BigInteger.java:476)
	at Ideone.main(Main.java:33)