Source code for submission s995

Main.java

  1.  
  2. import java.io.BufferedReader;
  3. import java.io.InputStreamReader;
  4.  
  5. /*
  6.  * To change this template, choose Tools | Templates
  7.  * and open the template in the editor.
  8.  */
  9.  
  10.  
  11.  
  12. /**
  13.  *
  14.  * @author cteam028
  15.  */
  16. public class Main {
  17.  
  18. /**
  19.   * @param args the command line arguments
  20.   */
  21. public static void main(String[] args) throws Exception {
  22. String line;
  23. while((line = br.readLine()) != null) {
  24. final int n = line.length();
  25. int[] vals = new int[n / 2 + 2];
  26. int[] newvals = new int[n/2 + 2];
  27. int[] tmp;
  28. vals[0] = 1;
  29.  
  30. for(int i = 0; i < n; i++)
  31. {
  32.  
  33. switch(line.charAt(i))
  34. {
  35. case '.':
  36. five(vals, newvals);
  37. tencp(vals, newvals);
  38. break;
  39. case '(':
  40. five(vals, newvals);
  41. break;
  42. case ')':
  43. ten(vals, newvals);
  44. break;
  45. }
  46. tmp = vals;
  47. vals = newvals;
  48. newvals = tmp;
  49. }
  50. System.out.println(Integer.toString(vals[0]));
  51.  
  52. }
  53. }
  54.  
  55. public static void five(int[] vals, int[] newvals)
  56. {
  57. for(int i = 0; i < vals.length - 1; i++)
  58. newvals[i+1] = vals[i];
  59. newvals[0] = 0;
  60. }
  61.  
  62. public static void ten(int[] vals, int[] newvals)
  63. {
  64. for(int i = 1; i < vals.length; i++)
  65. newvals[i-1] = vals[i];
  66. newvals[vals.length - 1] = 0;
  67. }
  68. public static void tencp(int[] vals, int[] newvals)
  69. {
  70. for(int i = 1; i < vals.length; i++)
  71. {
  72. newvals[i-1] += vals[i];
  73. newvals[i-1] = newvals[i-1] % 1000000;
  74. }
  75. }
  76.  
  77. }
  78.