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

using namespace std;

int get_middle(int a, int b) {
  return (a + b) / 2;
}

int new_begin(int a, int b) {
  return get_middle(a, b);
}

int new_end(int a, int b) {
  return get_middle(a, b) + (a + b) % 2;
}

int main() {
	int d = podajD();
	int t[d];
  int begin[d];
  int end[d];
  int r = podajR();
  int mid = get_middle(0, r);
	for(int i = 0; i < d; ++i) {
		t[i] = mid;
    begin[i] = 0;
    end[i] = r;
	}

	while(czyCieplo(t)) {
		for(int i = 0; i < d; ++i) {
			t[i] += 1;
		}
	}

  bool is_end = false;

  while (!is_end) {
    is_end = true;
    for (int i = 0; i < d; i++) {
      if (end[i] - begin[i] != 2 ) {
        t[i] = begin[i];
        int cieplo = czyCieplo(t);
        t[i] = end[i];
        cieplo = czyCieplo(t);
        if (cieplo) 
          begin[i] = new_begin(begin[i], end[i]);
        else 
          end[i] = new_end(begin[i], end[i]);
        t[i] = get_middle(begin[i], end[i]);

        if (end[i] - begin[i] != 2) {
          is_end = false;
        }
      }
    }
  }

  for (int i = 0; i < d; i++) {
    int cieplo1, cieplo2;
    t[i] = begin[i];
    cieplo1 = czyCieplo(t);
    t[i] = end[i];
    cieplo1 = czyCieplo(t);
    t[i] = begin[i];
    cieplo2 = czyCieplo(t);
    if (cieplo1) {
      t[i] = end[i];
    }
    else {
      if (cieplo2)
        t[i] = begin[i];
      else 
        t[i] = get_middle(begin[i], end[i]);
    }  
  }
  
	znalazlem(t);

}