#include "cielib.h" #include <algorithm> int main() { int d = podajD(), k = podajK(), r = podajR(); int point[500]; //int point2[500]; int lower[500]; int upper[500]; std::fill(lower, lower + d, 0); std::fill(upper, upper + d, r); while(r > 2) { const int half = r / 2; for (int i = 0; i < d; i++) point[i] = lower[i] + half; if (r % 2 != 0) { for (int i = 0; i < d; i++) { const int lowerCpy = lower[i]; point[i] = lower[i]; czyCieplo(point); point[i] = upper[i]; int cieplo = czyCieplo(point); if (cieplo == 1) lower[i]++; else upper[i]--; point[i] = lowerCpy + half; } } else { for (int i = 0; i < d; i++) { const int lowerCpy = lower[i]; point[i] = lower[i]; czyCieplo(point); point[i] = upper[i]; int cieplo = czyCieplo(point); if (cieplo == 1) lower[i] += half; else upper[i] -= half; point[i] = lowerCpy + half; } } r = upper[0] - lower[0]; } // r = 2 for (int i = 0; i < d; i++) point[i] = lower[i] + 1; //bool allZero = true; for (int i = 0; i < d; i++) { const int cpy = point[i]; point[i] = lower[i]; czyCieplo(point); point[i] = lower[i] + 2; int cieplo = czyCieplo(point); point[i] = lower[i]; int cieplo2 = czyCieplo(point); if(cieplo == 0 && cieplo2 == 0) { lower[i] = lower[i] + 1; } else if(cieplo == 0 && cieplo2 == 1) { lower[i] = lower[i]; } else { lower[i] = lower[i] + 2; } point[i] = cpy; } //if(allZero) //{ // int cieplo = czyCieplo(lower); // for(int i = 0; i < d; i++) // point[i] = lower[i] + 1; // cieplo = czyCieplo(lower); // if(cieplo == 0) // { // for (int i = 0; i < d; i++) // point[i] = lower[i]; // } //} znalazlem(lower); 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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | #include "cielib.h" #include <algorithm> int main() { int d = podajD(), k = podajK(), r = podajR(); int point[500]; //int point2[500]; int lower[500]; int upper[500]; std::fill(lower, lower + d, 0); std::fill(upper, upper + d, r); while(r > 2) { const int half = r / 2; for (int i = 0; i < d; i++) point[i] = lower[i] + half; if (r % 2 != 0) { for (int i = 0; i < d; i++) { const int lowerCpy = lower[i]; point[i] = lower[i]; czyCieplo(point); point[i] = upper[i]; int cieplo = czyCieplo(point); if (cieplo == 1) lower[i]++; else upper[i]--; point[i] = lowerCpy + half; } } else { for (int i = 0; i < d; i++) { const int lowerCpy = lower[i]; point[i] = lower[i]; czyCieplo(point); point[i] = upper[i]; int cieplo = czyCieplo(point); if (cieplo == 1) lower[i] += half; else upper[i] -= half; point[i] = lowerCpy + half; } } r = upper[0] - lower[0]; } // r = 2 for (int i = 0; i < d; i++) point[i] = lower[i] + 1; //bool allZero = true; for (int i = 0; i < d; i++) { const int cpy = point[i]; point[i] = lower[i]; czyCieplo(point); point[i] = lower[i] + 2; int cieplo = czyCieplo(point); point[i] = lower[i]; int cieplo2 = czyCieplo(point); if(cieplo == 0 && cieplo2 == 0) { lower[i] = lower[i] + 1; } else if(cieplo == 0 && cieplo2 == 1) { lower[i] = lower[i]; } else { lower[i] = lower[i] + 2; } point[i] = cpy; } //if(allZero) //{ // int cieplo = czyCieplo(lower); // for(int i = 0; i < d; i++) // point[i] = lower[i] + 1; // cieplo = czyCieplo(lower); // if(cieplo == 0) // { // for (int i = 0; i < d; i++) // point[i] = lower[i]; // } //} znalazlem(lower); return 0; } |