about summary refs log tree commit diff
path: root/codechef/maxep.c
blob: e92d9dfab8917814de09791a9ea6960bb5e02d18 (plain) (blame)
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
#include <stdio.h>

int main()
{
	long x = 1, y, n;
	int b, c, left = 1000;

	scanf("%ld %d", &n, &c);
	while (--left >= c && x < n) {
		printf("1 %ld\n", y = (x + n) / 2);
		fflush(stdout);

		scanf("%d", &b);
		if (b) {
			puts("2");
			fflush(stdout);
			left -= c;
			n = y;
		} else {
			x = y + 1;
		}
	}

	printf("3 %ld\n", x);
	return 0;
}