public class cie { public static void main(String[] args) { int d = cielib.podajD(); int k = cielib.podajK(); int r = cielib.podajR(); int[] min = new int[d]; int[] max = new int[d]; for (int i = 0; i < d; i++) { min[i] = 0; max[i] = r; } int ok = 0; int[] guess = new int[d]; boolean warm; while (ok < d) { int w = 0; for (int i = 0; i < d; i++) { guess[i] = (min[i] + max[i]) / 2; if (max[i] - min[i] > max[w] - min[w]) { w = i; } } guess[w] = min[w]; cielib.czyCieplo(guess); guess[w] = max[w]; warm = cielib.czyCieplo(guess) == 1; if (warm) { min[w] = (min[w] + max[w]) / 2 + 1; if (max[w] - min[w] == 1) min[w]--; } else if (max[w] - min[w] == 2) { guess[w] = min[w]; if (cielib.czyCieplo(guess) == 1) { max[w] = min[w]; } else { max[w]--; min[w]++; } } else { max[w] = (min[w] + max[w]) / 2 + 1; if (max[w] - min[w] == 1) max[w]++; } if (min[w] == max[w]) { ok++; } } cielib.znalazlem(min); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | public class cie { public static void main(String[] args) { int d = cielib.podajD(); int k = cielib.podajK(); int r = cielib.podajR(); int[] min = new int[d]; int[] max = new int[d]; for (int i = 0; i < d; i++) { min[i] = 0; max[i] = r; } int ok = 0; int[] guess = new int[d]; boolean warm; while (ok < d) { int w = 0; for (int i = 0; i < d; i++) { guess[i] = (min[i] + max[i]) / 2; if (max[i] - min[i] > max[w] - min[w]) { w = i; } } guess[w] = min[w]; cielib.czyCieplo(guess); guess[w] = max[w]; warm = cielib.czyCieplo(guess) == 1; if (warm) { min[w] = (min[w] + max[w]) / 2 + 1; if (max[w] - min[w] == 1) min[w]--; } else if (max[w] - min[w] == 2) { guess[w] = min[w]; if (cielib.czyCieplo(guess) == 1) { max[w] = min[w]; } else { max[w]--; min[w]++; } } else { max[w] = (min[w] + max[w]) / 2 + 1; if (max[w] - min[w] == 1) max[w]++; } if (min[w] == max[w]) { ok++; } } cielib.znalazlem(min); } } |