关于#python#NOI#的问题:#http://noi.openjudge.cn/ch0105/21/(操作系统-windows)

链接:http://noi.openjudge.cn/ch0105/21/
思路:

#http://noi.openjudge.cn/ch0105/21/
n = int(input())
if n == 1 :
    print("End")
else:
    if n % 2 == 0 :
        print(str(n)+"/2="+str(n//2))
        n = n // 2
    else :
        print(str(n)+"*3+1="+str(n*3+1))
        n = n * 3 + 1
    while True :
        if n == 1 :
            break
        print(str(n)+"/2="+str(n//2))
        n = n // 2
    print("End")

运行结果没有问题,但是题目判错。
求各位帮助!
样例及题目见链接

把判断错误的界面贴来看看。 超时还是结果错?

while true的循环里面,也要用上面的逻辑来处理,不要处理一次就以为完事了
比如一个偶数14,它除以2之后是7,那么就应该按照奇数的处理方式乘3加1了,不要继续除以2了啊

n = int(input())
while n!=1:
    if n % 2:
        print(str(n)+"*3+1="+str(n*3+1))
        n = n * 3 + 1
    else :
        print(str(n)+"/2="+str(n//2))
        n = n // 2
print("End")