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


void search(int r, int dim)
{
	int *pos = new int[dim];
	for (int i = 0; i < dim; ++i)
		pos[i] = 0;
	int k = 0;
	
	for(int i = 0; i < dim; i++)
	{
		int a = 0;
		int b = r;
		while(true)
		{
			if(a == b)
			{
				pos[i] = a;
				break;
			}
			int mid = a + (b-a)/2;
			pos[i] = mid;
			czyCieplo(pos);
			pos[i]--;
			if(czyCieplo(pos))
			{
				b = mid - 1;
				k += 2;
			}
			else
			{
				pos[i] += 2;
				k += 3;
				if(czyCieplo(pos))
					a = mid + 1;
				else
				{
					pos[i] = mid;
					break;
				}
			}
			
		}
	}
	znalazlem(pos);
}

int main()
{
	int d = podajD();
	int r = podajR();
	search(r, d);
	
	return 0;
}