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
#include "cielib.h"

int *tmp, *sL, *sH;

void findCord3(int d, int size)
{

    while (size > 3)
    {
        int sizeToKeep = size / 2;

        if (sizeToKeep == 2)
            sizeToKeep = 3;

        for (int i = 0; i < d; ++i)
        {
            tmp[i] = sL[i];
            czyCieplo(tmp);
            tmp[i] = sH[i];
            int c1 = czyCieplo(tmp);

            tmp[i] = sL[i];
            int c2 = czyCieplo(tmp);

            if (c1 == 1 && c2 == 0)
            {
                sL[i] = sH[i] - sizeToKeep + 1;
            }
            else if (c1 == 0 && c2 == 1)
            {
                sH[i] = sL[i] + sizeToKeep - 1;
            }
            else
            {
                sL[i] = sL[i] + size / 2 - sizeToKeep / 2 ;
                sH[i] = sL[i] + sizeToKeep - 1;
            }
            tmp[i] = (sL[i] + sH[i]) / 2;
        }
        size = sizeToKeep;
    }

    for (int i = 0; i < d; ++i)
    {
        int ml = sL[i] + 1;
        int mh = sH[i] - 1;

        tmp[i] = sL[i];
        czyCieplo(tmp);
        tmp[i] = mh;
        int c1 = czyCieplo(tmp);

        tmp[i] = sH[i];
        czyCieplo(tmp);
        tmp[i] = ml;
        int c2 = czyCieplo(tmp);

        if (c1 == 1 && c2 == 0)
        {
            sL[i] = sH[i];
        }
        else if (c1 == 0 && c2 == 1)
        {
            sH[i] = sL[i];
        }
        else
        {
            sH[i] = mh;
            sL[i] = mh;
        }
        tmp[i] = (sL[i] + sH[i]) / 2;
    }

}


int main()
{
    int d = podajD();
    int k = podajK();
    int r = podajR();

    tmp = new int[d];
    sH = new int[d];
    sL = new int[d];

    for (int i = 0; i < d; ++i)
    {
        sL[i] = 0;
        sH[i] = r;
        tmp[i] = r / 2;
    }

    findCord3(d, r + 1);

    znalazlem(sL);
    return 0;
}