我放在測試的地方可以AC
可是繳交答案就出現TLE
我想是因為我沒有限制1~1000000區間的原因
所以我想請問該怎麼限制?
還是有另外其他原因可以改善嗎?
感謝大家!
while True:
try:
var=1
while var==1:
i, j = [int(x) for x in input().split()]
m = 0
print (i,end=' ')
print (j,end=' ')
while i>j:
i,j = j,i
for n in range(i,j+1):
count = []
count.append(n)
while n != 1:
if n == 1:
break
elif n % 2 == 1:
n = n*3+1
count.append(n)
elif n % 2 == 0:
n = n/2
count.append(n)
if len(count) > m:
m = len(count)
else:
pass
del(count)
print (m,end=' ')
print ()
except:
break