aboutsummaryrefslogtreecommitdiff
path: root/15/open/gold/googol.py
diff options
context:
space:
mode:
Diffstat (limited to '15/open/gold/googol.py')
-rw-r--r--15/open/gold/googol.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/15/open/gold/googol.py b/15/open/gold/googol.py
new file mode 100644
index 0000000..5eeb3be
--- /dev/null
+++ b/15/open/gold/googol.py
@@ -0,0 +1,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);