#include "cielib.h"
int main()
{
int d, k, r;
d = podajD();
k = podajK();
r = podajR();
int pos[d];
for (int i = 0; i < d; i++)
{
pos[i] = 0;
}
czyCieplo(pos);
for (int i = 0; i < d; i++)
{
int start = 0;
int end = r;
int cpos = 0;
while (start != end)
{
if (end - cpos > cpos - start)
{
pos[i] = start + (end - cpos) / 2 + ((end - cpos) % 2 == 0 ? 0 : 1);
if (czyCieplo(pos))
{
start = pos[i] + (pos[i] - start) / 2 + 1;
}
else
{
end = pos[i];
}
}
else
{
pos[i] = start + (cpos - start) / 2;
if (czyCieplo(pos))
{
end = pos[i] + (end - pos[i])/2;
}
else
{
start = pos[i];
}
}
cpos = pos[i];
}
pos[i] = start;
}
znalazlem(pos);
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 | #include "cielib.h" int main() { int d, k, r; d = podajD(); k = podajK(); r = podajR(); int pos[d]; for (int i = 0; i < d; i++) { pos[i] = 0; } czyCieplo(pos); for (int i = 0; i < d; i++) { int start = 0; int end = r; int cpos = 0; while (start != end) { if (end - cpos > cpos - start) { pos[i] = start + (end - cpos) / 2 + ((end - cpos) % 2 == 0 ? 0 : 1); if (czyCieplo(pos)) { start = pos[i] + (pos[i] - start) / 2 + 1; } else { end = pos[i]; } } else { pos[i] = start + (cpos - start) / 2; if (czyCieplo(pos)) { end = pos[i] + (end - pos[i])/2; } else { start = pos[i]; } } cpos = pos[i]; } pos[i] = start; } znalazlem(pos); return 0; } |
English