Skip to content

Instantly share code, notes, and snippets.

@falsetru
Created October 16, 2013 07:53
Show Gist options
  • Save falsetru/7004147 to your computer and use it in GitHub Desktop.
Save falsetru/7004147 to your computer and use it in GitHub Desktop.
우박 수열
import functools
import sys
@functools.lru_cache(maxsize=None) # Python 3.2+
def f(n):
if n == 1:
return 1
elif n % 2 == 0:
return 1 + f(n // 2)
else:
return 1 + f(n * 3 + 1)
def solve(i, j):
return max(map(f, range(i, j+1)))
for line in sys.stdin:
i, j = map(int, line.split())
print(i, j, solve(i, j))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment