diff options
author | Ta180m | 2019-08-16 21:44:37 -0500 |
---|---|---|
committer | GitHub | 2019-08-16 21:44:37 -0500 |
commit | 2f5d998595c239c6441f88cb5003f870b8f285f3 (patch) | |
tree | daadc35753e9dbead4e9a9ee24b69adcde7dd4dc | |
parent | bddf3a2de22a7ed872ea9e00e834874e4c4a3565 (diff) |
Create googol.py
-rw-r--r-- | 2015/US Open/Gold/googol.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/2015/US Open/Gold/googol.py b/2015/US Open/Gold/googol.py new file mode 100644 index 0000000..483fac8 --- /dev/null +++ b/2015/US Open/Gold/googol.py @@ -0,0 +1,15 @@ +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 + if d % 2 == 0: + return (d >> 1) + solve(b, (d >> 1)) + 1 + else: + return (d >> 1) + solve(a, (d >> 1) + 1) + 1 + +ans = solve(1, -1); +print("Answer", ans); |