public void solve(int testNumber, InputReader in, PrintWriter out) { in.readCharacter(); in.readCharacter(); String first = in.readString(); in.readCharacter(); in.readCharacter(); String second = in.readString(); int result = go( Integer.parseInt(first) * TEN[6 - first.length()], Integer.parseInt(second) * TEN[6 - second.length()]); out.println("Case " + testNumber + ": " + result); }
public void solve(int testNumber, InputReader in, PrintWriter out) { int n = in.readInt(); int[] a = new int[n]; int s = 0; for (int i = 0; i < n; i++) { a[i] = in.readInt() * (n + 1); s += a[i]; } s /= n + 1; int over = 0; for (int i = 0; i < n; i++) { over += Math.max(a[i] - s, 0); } for (int i = 0; i < n; i++) { out.print(Math.max(a[i] - s, 0) * 100 / over + " "); } }
public void solve(int testNumber, net.egork.utils.old.io.old.InputReader in, PrintWriter out) { int count = in.readInt(); int[] numbers = IOUtils.readIntArray(in, count); Arrays.sort(numbers); int[] result = new int[count]; for (int i = 0; i < count; i += 2) result[i / 2] = numbers[i]; for (int i = 1; i < count; i += 2) result[count - 1 - i / 2] = numbers[i]; IOUtils.printArray(result, out); }
public void solve(int testNumber, net.egork.utils.old.io.old.InputReader in, PrintWriter out) { String first = in.readLine(false); String second = in.readLine(false); int length = first.length(); if (length != second.length()) { out.println("-1 -1"); return; } int[] prefix = StringUtils.prefixFunction(StringUtils.reverse(first) + '\n' + second); int[] z = StringUtils.zAlgorithm(second + '\n' + first + '\n'); int firstIndex = -1; int secondIndex = -1; for (int i = 0; i < length - 1; i++) { if (first.charAt(i) != second.charAt(length - i - 1)) break; int aLength = i + 1; int bLength = z[length + i + 2]; int cLength = prefix[2 * length - i - 1]; if (cLength > 0 && aLength + bLength + cLength >= length) { firstIndex = i; secondIndex = length - cLength; } } out.println(firstIndex + " " + secondIndex); }
public void solve(int testNumber, InputReader in, PrintWriter out) { int rowCount = in.readInt(); int columnCount = in.readInt(); char[][] table = in.readTable(4 * rowCount + 1, 4 * columnCount + 1); int[][] type = new int[rowCount][columnCount]; for (int i = 0; i < rowCount; i++) { for (int j = 0; j < columnCount; j++) { for (char[][] domino : vertical) { boolean valid = true; for (int k = 0; k < 3; k++) { for (int l = 0; l < 3; l++) { if (table[4 * i + 1 + k][4 * j + 1 + l] != domino[k][l]) valid = false; } } if (valid) type[i][j]++; } for (char[][] domino : horizontal) { boolean valid = true; for (int k = 0; k < 3; k++) { for (int l = 0; l < 3; l++) { if (table[4 * i + 1 + k][4 * j + 1 + l] != domino[k][l]) valid = false; } } if (valid) type[i][j] += 2; } } } long[] answer = new long[columnCount + 1]; answer[0] = 1; for (int i = 0; i < columnCount; i++) { boolean isVerticalRow = true; for (int j = 0; j < rowCount && isVerticalRow; j++) { if (type[j][i] == 2) isVerticalRow = false; } if (isVerticalRow && rowCount % 2 == 0) answer[i + 1] = (answer[i + 1] + answer[i]) % MOD; if (i == columnCount - 1) continue; long[] count = new long[2]; long[] nextCount = new long[2]; count[0] = 1; boolean isSecondRowVertical = true; for (int j = 0; j < rowCount && isSecondRowVertical; j++) { if (type[j][i + 1] == 2) isSecondRowVertical = false; } for (int j = 0; j < rowCount; j++) { nextCount[0] = nextCount[1] = 0; if (type[j][i] >= 2 && type[j][i + 1] >= 2) nextCount[0] = count[0]; nextCount[0] += count[1]; if (j == rowCount - 1) { long[] temp = nextCount; nextCount = count; count = temp; continue; } boolean firstVertical = (type[j][i] & 1) != 0 && (type[j + 1][i] & 1) != 0; boolean secondVertical = (type[j][i + 1] & 1) != 0 && (type[j + 1][i + 1] & 1) != 0; if (firstVertical && secondVertical) nextCount[1] += count[0]; nextCount[0] %= MOD; nextCount[1] %= MOD; long[] temp = nextCount; nextCount = count; count = temp; } if (isVerticalRow && isSecondRowVertical && rowCount % 2 == 0) count[0] = (count[0] + MOD - 1) % MOD; answer[i + 2] = (answer[i] * count[0]) % MOD; } out.println(answer[columnCount]); }