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

int t[500];
int lo[500];
int hi[500];

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

	for(int i = 0; i < d; i++) {
		t[i] = r/2;
		hi[i] = r;
	}
	
	int found = 0;
	
	while(hi[0] - lo[0] > 1) {
		for(int i = 0; i < d; i++) {

			t[i] = lo[i];
			czyCieplo(t);
			t[i] = hi[i];
			
			if(czyCieplo(t)) 
				lo[i] = (hi[i]+lo[i])>>1;
			else 
				hi[i] = (hi[i]+lo[i]+1)>>1;
				
			t[i] = (hi[i]+lo[i])>>1;  	
		}
	}
	for(int i = 0; i < d; i++) {
		if(lo[i] == 0) {
			t[i] = 2;
			czyCieplo(t);
			t[i] = 0;
			if(!czyCieplo(t))
				t[i] = 1;		
		}
		else t[i]++;
	}
		
	znalazlem(t);
}