#include "cielib.h" const int N = 500; int ret, L[N], R[N], p[N], ans[N]; int main() { int d = podajD(), r = podajR(); for (int i = 0; i < d; ++i) L[i] = 0, R[i] = r; while (r > 2) { for (int i = 0; i < d; ++i) { for (int j = 0; j < d; ++j) p[j] = (L[j] + R[j]) / 2; p[i] = L[i]; czyCieplo(p); p[i] = R[i]; ret = czyCieplo(p); if (ret == 1) L[i] += r / 2; else R[i] -= r / 2; } r -= r / 2; } for (int i = 0; i < d; ++i) { for (int j = 0; j < d; ++j) p[j] = (L[j] + R[j]) / 2; p[i] = L[i]; czyCieplo(p); p[i] = R[i]; ret = czyCieplo(p); if (ret == 1) { ans[i] = R[i]; continue; } p[i] = L[i]; ret = czyCieplo(p); if (ret == 1) { ans[i] = L[i]; continue; } ans[i] = L[i] + 1; } znalazlem(ans); }
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 | #include "cielib.h" const int N = 500; int ret, L[N], R[N], p[N], ans[N]; int main() { int d = podajD(), r = podajR(); for (int i = 0; i < d; ++i) L[i] = 0, R[i] = r; while (r > 2) { for (int i = 0; i < d; ++i) { for (int j = 0; j < d; ++j) p[j] = (L[j] + R[j]) / 2; p[i] = L[i]; czyCieplo(p); p[i] = R[i]; ret = czyCieplo(p); if (ret == 1) L[i] += r / 2; else R[i] -= r / 2; } r -= r / 2; } for (int i = 0; i < d; ++i) { for (int j = 0; j < d; ++j) p[j] = (L[j] + R[j]) / 2; p[i] = L[i]; czyCieplo(p); p[i] = R[i]; ret = czyCieplo(p); if (ret == 1) { ans[i] = R[i]; continue; } p[i] = L[i]; ret = czyCieplo(p); if (ret == 1) { ans[i] = L[i]; continue; } ans[i] = L[i] + 1; } znalazlem(ans); } |