#include "cielib.h"
int main () {
int d = podajD();
int r = podajR();
int start = r >> 1;
int i, low, high, l, h, m, max_multiplier, dim_max, j, c;
int vertex[d], inside[d], point[d], other_end[d];
for (i = 0; i < d; ++i) {
point[i] = start;
}
if (d > 1) {
czyCieplo(point);
for (i = 0; i < d; ++i) {
point[i] = 0;
czyCieplo(point);
point[i] = start;
low = czyCieplo(point);
if (low) {
l = 0;
h = start;
while (h - l > 1) {
m = (h + l) / 2;
point[i] = m;
czyCieplo(point);
point[i] = start;
if (czyCieplo(point)) {
l = m;
}
else {
h = m;
}
}
point[i] = l;
czyCieplo(point);
point[i] = start;
if (czyCieplo(point)) {
vertex[i] = h;
}
else {
vertex[i] = l;
}
inside[i] = 1;
continue;
}
point[i] = r;
czyCieplo(point);
point[i] = start;
high = czyCieplo(point);
if (high) {
l = start;
h = r;
while (h - l > 1) {
m = (h + l) / 2;
point[i] = m;
czyCieplo(point);
point[i] = start;
if (czyCieplo(point)) {
h = m;
}
else {
l = m;
}
}
point[i] = h;
czyCieplo(point);
point[i] = start;
if (czyCieplo(point)) {
vertex[i] = l;
}
else {
vertex[i] = h;
}
inside[i] = -1;
}
else if (r % 2 == 0) {
vertex[i] = 0;
inside[i] = 1;
}
else {
inside[i] = 0;
}
}
if (r % 2) {
for (i = 0; i < d; ++i) {
if (inside[i]) {
continue;
}
czyCieplo(point);
point[i] = 0;
for (j = 0; j < d; ++j) {
point[j] += inside[j];
}
c = czyCieplo(point);
for (j = 0; j < d; ++j) {
point[j] -= inside[j];
}
point[i] = start;
if (c) {
vertex[i] = r;
inside[i] = -1;
}
else {
vertex[i] = 0;
inside[i] = 1;
}
}
}
}
else {
vertex[0] = 0;
inside[0] = 1;
}
max_multiplier;
for (i = 0; i < d; ++i) {
dim_max = (inside[i] == 1) ? (r - vertex[i]) : vertex[i];
if (!i) {
max_multiplier = dim_max;
}
else if (dim_max < max_multiplier) {
max_multiplier = dim_max;
}
}
czyCieplo(vertex);
other_end[d];
for (i = 0; i < d; ++i) {
other_end[i] = vertex[i] + max_multiplier * inside[i];
}
if (czyCieplo(other_end)) {
for (i = 0; i < d; ++i) {
vertex[i] = other_end[i];
inside[i] = -inside[i];
}
}
l = 0;
h = max_multiplier;
while (h - l > 1) {
m = (h + l) / 2;
for (i = 0; i < d; ++i) {
point[i] = vertex[i] + inside[i] * m;
}
czyCieplo(vertex);
if (czyCieplo(point)) {
l = m;
}
else {
h = m;
}
}
for (i = 0; i < d; ++i) {
point[i] = vertex[i] + inside[i] * l;
}
czyCieplo(vertex);
if (!czyCieplo(point)) {
h = l;
}
for (i = 0; i < d; ++i) {
point[i] = vertex[i] + inside[i] * h / 2;
}
znalazlem(point);
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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | #include "cielib.h" int main () { int d = podajD(); int r = podajR(); int start = r >> 1; int i, low, high, l, h, m, max_multiplier, dim_max, j, c; int vertex[d], inside[d], point[d], other_end[d]; for (i = 0; i < d; ++i) { point[i] = start; } if (d > 1) { czyCieplo(point); for (i = 0; i < d; ++i) { point[i] = 0; czyCieplo(point); point[i] = start; low = czyCieplo(point); if (low) { l = 0; h = start; while (h - l > 1) { m = (h + l) / 2; point[i] = m; czyCieplo(point); point[i] = start; if (czyCieplo(point)) { l = m; } else { h = m; } } point[i] = l; czyCieplo(point); point[i] = start; if (czyCieplo(point)) { vertex[i] = h; } else { vertex[i] = l; } inside[i] = 1; continue; } point[i] = r; czyCieplo(point); point[i] = start; high = czyCieplo(point); if (high) { l = start; h = r; while (h - l > 1) { m = (h + l) / 2; point[i] = m; czyCieplo(point); point[i] = start; if (czyCieplo(point)) { h = m; } else { l = m; } } point[i] = h; czyCieplo(point); point[i] = start; if (czyCieplo(point)) { vertex[i] = l; } else { vertex[i] = h; } inside[i] = -1; } else if (r % 2 == 0) { vertex[i] = 0; inside[i] = 1; } else { inside[i] = 0; } } if (r % 2) { for (i = 0; i < d; ++i) { if (inside[i]) { continue; } czyCieplo(point); point[i] = 0; for (j = 0; j < d; ++j) { point[j] += inside[j]; } c = czyCieplo(point); for (j = 0; j < d; ++j) { point[j] -= inside[j]; } point[i] = start; if (c) { vertex[i] = r; inside[i] = -1; } else { vertex[i] = 0; inside[i] = 1; } } } } else { vertex[0] = 0; inside[0] = 1; } max_multiplier; for (i = 0; i < d; ++i) { dim_max = (inside[i] == 1) ? (r - vertex[i]) : vertex[i]; if (!i) { max_multiplier = dim_max; } else if (dim_max < max_multiplier) { max_multiplier = dim_max; } } czyCieplo(vertex); other_end[d]; for (i = 0; i < d; ++i) { other_end[i] = vertex[i] + max_multiplier * inside[i]; } if (czyCieplo(other_end)) { for (i = 0; i < d; ++i) { vertex[i] = other_end[i]; inside[i] = -inside[i]; } } l = 0; h = max_multiplier; while (h - l > 1) { m = (h + l) / 2; for (i = 0; i < d; ++i) { point[i] = vertex[i] + inside[i] * m; } czyCieplo(vertex); if (czyCieplo(point)) { l = m; } else { h = m; } } for (i = 0; i < d; ++i) { point[i] = vertex[i] + inside[i] * l; } czyCieplo(vertex); if (!czyCieplo(point)) { h = l; } for (i = 0; i < d; ++i) { point[i] = vertex[i] + inside[i] * h / 2; } znalazlem(point); return 0; } |
English