Skip to content

Instantly share code, notes, and snippets.

@falsetru
Created Oct 16, 2013
Embed
What would you like to do?
우박 수열
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