当前位置: 高中信息技术 / 单选题
  • 1. (2023高三下·浙江月考) 有如下Python程序段:

    n=int(input())

    a=1;q=[0]*100;two=three=rear=0;q[0]=a

    while rear!=n:

        if(2*q[two]+1>3*q[three]+1):

            rear+=1

            q[rear]=3*q[three]+1

            three+=1

        elif(2*q[two]+1<3*q[three]+1):

            rear+=1

            q[rear]=2*q[two]+1

            two+=1

        else:

            rear+=1

            q[rear]=3*q[three]+1

            two+=1;three+=1

    运行上述程序段后,如果输入10,则q[n]的值是(   )

    A . 15 B . 22 C . 27 D . 31

微信扫码预览、分享更方便