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

using namespace std;

int d, r, n, m;
int tab[505];
int X[505];
int Y[505];
int x[505];
int y[505];

int main ()
{
	d = podajD();
	r = podajR();
	for (int i = 0; i < d; ++i)
	{
		X[i] = 0;
		Y[i] = r;
	}
	n = r;
	while (n > 1)
	{
		for (int i = 0; i < d; ++i)
		{
			for (int j = 0; j < d; ++j) tab[j] = (X[j] + Y[j]) / 2;
			tab[i] = X[i];
			czyCieplo(tab);
			tab[i] = Y[i];
			m = czyCieplo(tab);
			if (m == 1)
			{
				x[i] = (X[i] + Y[i]) / 2;
				y[i] = Y[i];
			}
			else
			{
				x[i] = X[i];
				y[i] = (X[i] + Y[i] + 1) / 2;
			}
		}
		for (int i = 0; i < d; ++i)
		{
			X[i] = x[i];
			Y[i] = y[i];
		}
		n = (n + 1) / 2;
	}
	for (int i = 0; i < d; ++i)
	{
		for (int j = 0; j < d; ++j) tab[j] = X[j];
		if (X[i] == 0)
		{
			tab[i] = 2;
			czyCieplo(tab);
			tab[i] = 0;
			m = czyCieplo(tab);
			if (m == 1)
			{
				tab[i] = 1;
				m = czyCieplo(tab);
				if (m == 1) x[i] = 1;
				else x[i] = 0;
			}
			else x[i] = 1;
		}
		else
		{
			tab[i] = X[i] - 1;
			czyCieplo(tab);
			tab[i] = Y[i];
			m = czyCieplo(tab);
			if (m == 1)
			{
				tab[i] = X[i];
				m = czyCieplo(tab);
				if (m == 1) x[i] = X[i];
				else x[i] = Y[i];
			}
			else x[i] = X[i];
		}
	}
	znalazlem(x);
	return 0;
}