#include "cielib.h" #include <algorithm> using namespace std; static const int MAX_D = 500; int R, r; int d; int a[MAX_D]; int b[MAX_D]; int q[MAX_D]; int main() { d = podajD(); R = r = podajR(); for (int i = 0; i < d; i++) a[i] = 0; while (r > 2) { int m = r / 2; for (int i = 0; i < d; i++) q[i] = a[i] + m; for (int i = 0; i < d; i++) { q[i] = a[i] + r; czyCieplo(q); q[i] = a[i]; if (czyCieplo(q)) b[i] = a[i]; else b[i] = a[i] + m; q[i] = a[i] + m; } r = (r + 1) / 2; for (int i = 0; i < d; i++) a[i] = min(b[i] + r, R) - r; } { for (int i = 0; i < d; i++) q[i] = a[i] + 1; for (int i = 0; i < d; i++) { q[i] = a[i] + 2; czyCieplo(q); q[i] = a[i]; if (czyCieplo(q)) b[i] = a[i]; else { q[i] = a[i] + 2; if (czyCieplo(q)) b[i] = a[i] + 2; else b[i] = a[i] + 1; } q[i] = a[i] + 1; } } znalazlem(b); }
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 | #include "cielib.h" #include <algorithm> using namespace std; static const int MAX_D = 500; int R, r; int d; int a[MAX_D]; int b[MAX_D]; int q[MAX_D]; int main() { d = podajD(); R = r = podajR(); for (int i = 0; i < d; i++) a[i] = 0; while (r > 2) { int m = r / 2; for (int i = 0; i < d; i++) q[i] = a[i] + m; for (int i = 0; i < d; i++) { q[i] = a[i] + r; czyCieplo(q); q[i] = a[i]; if (czyCieplo(q)) b[i] = a[i]; else b[i] = a[i] + m; q[i] = a[i] + m; } r = (r + 1) / 2; for (int i = 0; i < d; i++) a[i] = min(b[i] + r, R) - r; } { for (int i = 0; i < d; i++) q[i] = a[i] + 1; for (int i = 0; i < d; i++) { q[i] = a[i] + 2; czyCieplo(q); q[i] = a[i]; if (czyCieplo(q)) b[i] = a[i]; else { q[i] = a[i] + 2; if (czyCieplo(q)) b[i] = a[i] + 2; else b[i] = a[i] + 1; } q[i] = a[i] + 1; } } znalazlem(b); } |