Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. /*
  4. PROG: paren
  5. LANG: JAVA
  6. ID: jtogether1
  7. */
  8.  
  9. public class paren {
  10. public static void main(String[] Args) throws IOException {
  11. // Use BufferedReader rather than RandomAccessFile; it's much faster
  12. BufferedReader in = new BufferedReader(new FileReader("paren.in"));
  13. // input file name goes above
  14. PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
  15. "paren.out")));
  16.  
  17. int numparen = Integer.parseInt(in.readLine());
  18. long[] digit = new long[numparen];
  19. long modthingy = 0;
  20. for (int x = 1; x < 10; x++) {
  21. modthingy = modthingy * 10 + x;
  22. }
  23. modthingy = modthingy * 100 + 10;
  24.  
  25. for (int x = 0; x < numparen; x++) {
  26. digit[x] = 0 - Integer.parseInt(in.readLine());
  27. int y = x;
  28. long value = 0;
  29. if (digit[y] == -1) {
  30. while (digit[y] != 0) {
  31. if (digit[y] > 0) {
  32. value += digit[y];
  33. digit[y] = -1;
  34. }
  35. y--;
  36. }
  37.  
  38. digit[y] = value * 2 % modthingy;
  39. if (digit[y] == 0) {
  40. digit[y] = 1;
  41. }
  42. }
  43. }
  44.  
  45. for (int x = 1; x < numparen; x++) {
  46. if (digit[x] > 0) {
  47. digit[0] = (digit[0] + digit[x]) % modthingy;
  48. }
  49. }
  50.  
  51. out.println(digit[0] % modthingy);
  52. out.close(); // close the output file
  53. System.exit(0); // don't omit this!
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement