fork(3) download
  1. import java.io.OutputStream;
  2. import java.io.IOException;
  3. import java.io.PrintWriter;
  4. import java.util.InputMismatchException;
  5. import java.io.InputStream;
  6.  
  7. /**
  8.  * Built using CHelper plug-in
  9.  * Actual solution is at the top
  10.  * @author emotionalBlind
  11.  */
  12. public class Main {
  13. public static void main(String[] args) {
  14. InputStream inputStream = System.in;
  15. OutputStream outputStream = System.out;
  16. InputReader in = new InputReader(inputStream);
  17. PrintWriter out = new PrintWriter(outputStream);
  18. LOJ_1006 solver = new LOJ_1006();
  19. solver.solve(1, in, out);
  20. out.close();
  21. }
  22. }
  23.  
  24. class LOJ_1006 {
  25. public void solve(int testNumber, InputReader in, PrintWriter out) {
  26. int T = in.readInt();
  27. int[] a = new int[10001];
  28. int MOD = 10000007;
  29. for (int t = 1; t <= T; ++t) {
  30. for (int i = 0; i < 6; ++i) {
  31. a[i] = in.readInt();
  32. a[i] %= MOD;
  33. }
  34. int n = in.readInt();
  35. for (int i = 6; i <= n; ++i) {
  36. long sum = 0;
  37. for (int j = 1; j <= 6; ++j) {
  38. sum = (sum + a[i - j]) % MOD;
  39. }
  40. a[i] = (int) sum;
  41. }
  42. out.printf("Case %d: %d\n", t, a[n]);
  43. }
  44. }
  45. }
  46.  
  47. class InputReader {
  48.  
  49. private InputStream stream;
  50. private byte[] buf = new byte[1024];
  51. private int curChar;
  52. private int numChars;
  53.  
  54. public InputReader(InputStream stream) {
  55. this.stream = stream;
  56. }
  57.  
  58. public int read() {
  59. if (numChars == -1)
  60. throw new InputMismatchException();
  61. if (curChar >= numChars) {
  62. curChar = 0;
  63. try {
  64. numChars = stream.read(buf);
  65. } catch (IOException e) {
  66. throw new InputMismatchException();
  67. }
  68. if (numChars <= 0)
  69. return -1;
  70. }
  71. return buf[curChar++];
  72. }
  73.  
  74. public int readInt() {
  75. int c = read();
  76. while (isSpaceChar(c))
  77. c = read();
  78. int sgn = 1;
  79. if (c == '-') {
  80. sgn = -1;
  81. c = read();
  82. }
  83. int res = 0;
  84. do {
  85. if (c < '0' || c > '9')
  86. throw new InputMismatchException();
  87. res *= 10;
  88. res += c - '0';
  89. c = read();
  90. } while (!isSpaceChar(c));
  91. return res * sgn;
  92. }
  93.  
  94. public long readLong() {
  95. int c = read();
  96. while (isSpaceChar(c))
  97. c = read();
  98. int sgn = 1;
  99. if (c == '-') {
  100. sgn = -1;
  101. c = read();
  102. }
  103. long res = 0;
  104. do {
  105. if (c < '0' || c > '9')
  106. throw new InputMismatchException();
  107. res *= 10;
  108. res += c - '0';
  109. c = read();
  110. } while (!isSpaceChar(c));
  111. return res * sgn;
  112. }
  113.  
  114. public static boolean isSpaceChar(int c) {
  115. return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
  116. }
  117.  
  118. public String next() {
  119. String s = new String("");
  120. int c = read();
  121. while (isSpaceChar(c)) c = read();
  122. do {
  123. s += c;
  124. c = read();
  125. } while (!isSpaceChar(c));
  126. return s;
  127. }
  128.  
  129. }
  130.  
  131.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty