#include <cstdio> #include "cielib.h" int d, r, mn[500], mx[500], tmp[500]; int dimension() { if (d == 1) { return 0; } int result = 0; int diff = mx[0] - mn[0]; for (int i = 1; i < d; i++) { int diff_temp = mx[i] - mn[i]; if (diff_temp > diff) { diff = diff_temp; result = i; } } return result; } int main() { d = podajD(); r = podajR(); for (int i = 0; i < d; i++) { mx[i] = r; } while (true) { int dim = dimension(); if (mn[dim] == mx[dim]) { break; } for (int i = 0; i < d; i++) { tmp[i] = (mn[i] + mx[i]) >> 1; } int c = tmp[dim]; tmp[dim] = mn[dim]; czyCieplo(tmp); tmp[dim] = mx[dim]; int cieplo = czyCieplo(tmp); if (cieplo) { mn[dim] = c + 1; } else { mx[dim] = c; } } znalazlem(mn); return 0; }
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | #include <cstdio> #include "cielib.h" int d, r, mn[500], mx[500], tmp[500]; int dimension() { if (d == 1) { return 0; } int result = 0; int diff = mx[0] - mn[0]; for (int i = 1; i < d; i++) { int diff_temp = mx[i] - mn[i]; if (diff_temp > diff) { diff = diff_temp; result = i; } } return result; } int main() { d = podajD(); r = podajR(); for (int i = 0; i < d; i++) { mx[i] = r; } while (true) { int dim = dimension(); if (mn[dim] == mx[dim]) { break; } for (int i = 0; i < d; i++) { tmp[i] = (mn[i] + mx[i]) >> 1; } int c = tmp[dim]; tmp[dim] = mn[dim]; czyCieplo(tmp); tmp[dim] = mx[dim]; int cieplo = czyCieplo(tmp); if (cieplo) { mn[dim] = c + 1; } else { mx[dim] = c; } } znalazlem(mn); return 0; } |