#54245: TLE problem


11330317@sssh.tp.edu.tw (S11330317劉鎬維)


 

第0個 test TLE killed 誰來幫我看看,求救



import sys

 

for line in sys.stdin:
    count = 0
    if not line or line == "\n" or line == "":
        break
    theList = line.strip().split()
    theList = list(map(int, theList))
    if theList[1] > 0 and theList[1] < theList[0]:
        break
    if theList[1] < 0 and theList[0] < theList[1]:
        break
    while True:
        count += 1
        theList[0] += theList[0] + count
        if theList[0] > theList[1]:
            print(count+1)
            break

 

#54246: Re: TLE problem


leeguanhan0909@gmail.com (李冠翰)


 

第0個 test TLE killed 誰來幫我看看,求救



import sys

 

for line in sys.stdin:
    count = 0
    if not line or line == "\n" or line == "":
        break
    theList = line.strip().split()
    theList = list(map(int, theList))
    if theList[1] > 0 and theList[1] < theList[0]:
        break
    if theList[1] < 0 and theList[0] < theList[1]:
        break
    while True:
        count += 1
        theList[0] += theList[0] + count
        if theList[0] > theList[1]:
            print(count+1)
            break

while True裡面的the list[0]是不斷更改的,如果n<=-2且m>0,就會TLE

可以試試看print(the list)就知道了