fork download
  1. package spoj;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. //import java.util.Scanner;
  7. import java.util.StringTokenizer;
  8.  
  9. public class ACODE {
  10.  
  11. static class FastReader
  12. {
  13.  
  14. public FastReader()
  15. {
  16. br = new BufferedReader(new
  17. }
  18.  
  19. String next()
  20. {
  21. while (st == null || !st.hasMoreElements())
  22. {
  23. try
  24. {
  25. st = new StringTokenizer(br.readLine());
  26. }
  27. catch (IOException e)
  28. {
  29. e.printStackTrace();
  30. }
  31. }
  32. return st.nextToken();
  33. }
  34.  
  35. int nextInt()
  36. {
  37. return Integer.parseInt(next());
  38. }
  39.  
  40. long nextLong()
  41. {
  42. return Long.parseLong(next());
  43. }
  44.  
  45. double nextDouble()
  46. {
  47. return Double.parseDouble(next());
  48. }
  49.  
  50. String nextLine()
  51. {
  52. String str = "";
  53. try
  54. {
  55. str = br.readLine();
  56. }
  57. catch (IOException e)
  58. {
  59. e.printStackTrace();
  60. }
  61. return str;
  62. }
  63. }
  64.  
  65. public static int recursive (String s)
  66. {
  67. if (s.length()==1)
  68. {
  69. if (s.charAt(0)!='0')
  70. return 1;
  71. if (s.charAt(0)=='0')
  72. return 0;
  73. }
  74. if (s.length()==2)
  75. {
  76. int m = stringToInt(s);
  77. if (m>=10 && m<=26)
  78. {
  79. if (s.charAt(1)!='0')
  80. return 2;
  81. if (s.charAt(1)=='0')
  82. return 1;
  83. }
  84. if (m<10 && m>26)
  85. return 0;
  86. }
  87. int m = stringToInt(s.substring(0, 2));
  88. if (m<10)
  89. return 0;
  90. if (m>=10 && m<=26)
  91. return recursive(s.substring(1))+recursive(s.substring(2));
  92. return recursive(s.substring(1));
  93. }
  94.  
  95. public static int stringToInt(String s)
  96. {
  97. int numberAtTens = (int)(s.charAt(0))-48;
  98. int numberAtOnes = (int)(s.charAt(1))-48;
  99. return (10*numberAtTens)+numberAtOnes;
  100. }
  101.  
  102. public static void main(String[] args){
  103. // TODO Auto-generated method stub
  104. FastReader s=new FastReader();
  105. String input=s.next();
  106. while(!input.equals("0"))
  107. {
  108. System.out.println(recursive(input));
  109. input = s.next();
  110. if (input.equals("0"))
  111. break;
  112. }
  113. }
  114.  
  115. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:9: error: class ACODE is public, should be declared in a file named ACODE.java
public class ACODE {
       ^
1 error
stdout
Standard output is empty