36 lines
646 B
Python
36 lines
646 B
Python
import sys
|
|
|
|
def ask(a):
|
|
print(a)
|
|
sys.stdout.flush()
|
|
return int(input())
|
|
|
|
def main():
|
|
# max distance, size of p
|
|
m, n = [int(i) for i in input().split()]
|
|
|
|
answers = []
|
|
for i in range(n):
|
|
a = ask(m)
|
|
if a == 0:
|
|
return
|
|
answers.append(a)
|
|
|
|
asked = n
|
|
ppos = 0
|
|
lower, upper = 1, m-1
|
|
while asked < 60:
|
|
curr = lower + (upper-lower)//2
|
|
a = ask(curr)
|
|
asked += 1
|
|
if a*answers[ppos%n] == 1:
|
|
upper = curr -1
|
|
elif a*answers[ppos%n] == -1:
|
|
lower = curr +1
|
|
else:
|
|
return
|
|
ppos += 1
|
|
|
|
|
|
main()
|