Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- sys.setrecursionlimit(100000)
- conteo =dict()
- def funcion(n):
- if n == 1:
- return 1
- else:
- if n % 2 == 0:
- if conteo.get(int(n/2))!=None:
- return conteo[int(n/2)]+1
- else:
- return 1+funcion(int(n/2))
- else:
- if conteo.get(3*n+1)!=None:
- return conteo[3*n+1]+1
- else:
- return 1+funcion(3*n+1)
- while True:
- try:
- entrada = input()
- entradaS = list(filter(lambda x:x!='',entrada.split(" ")))
- if(len(entradaS)==2):
- i = int(entradaS[0])
- j = int(entradaS[1])
- finali,finalj=i,j
- if i>j: i,j=j,i
- max = 0
- for n in range(i,j+1):
- if conteo.get(n)==None:
- cnt = funcion(n)
- conteo[n]=cnt
- else:
- cnt = conteo[n]
- if cnt>max:
- max=cnt
- print(finali,finalj,max)
- except EOFError:
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement