aboutsummaryrefslogtreecommitdiff
path: root/15/open/gold/googol.py
blob: 5eeb3be686ff44adff2e88298f0151bcada09ca3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
def solve(u, d):
	print(u)
	a, b = map(int, input().split())
	if b == 0:
		return (a > 0) + 1
	if d == -1:
		d = 2 * solve(a, -1) + 1
	d = d - 1
	return (d >> 1) + solve(a if d % 2 == 1 else b, (d >> 1) + (d % 2)) + 1

ans = solve(1, -1);
print("Answer", ans);