herofly


私信TA

用户名:pyhero

访问量:15649

签 名:

等  级
排  名 33
经  验 14104
参赛次数 17
文章发表 321
年  龄 0
在职情况 待业
学  校
专  业

  自我简介:

解题思路:所有人看成一个列表,报到3时出圈看成3之前的人移到列表最后去,继续报3再移到后面去直到只乘2人,第一个报1和3出圈
n = int(input())
if n ==1:
    print(1)
else:
    ls = list(range(1,n+1):
    while len(ls)>2:  #循环执行
        lt = ls[:2]   #去掉3后要移到最的列表前部分
        lh = ls[3:]   #去掉3后后半部分
        ls = lh+lt    #把两部分连起来
    print(ls[1])


 

0.0分

2 人评分

  评论区

#稍微完善了一下
n = int(input())
if n ==1:
    print(1)
else:
    ls = list(range(1,n+1))
    n = ls
    while len(ls)>2:
        lt = ls[:2]
        lh = ls[3:]
        ls = lh+lt
    if len(ls) == 2:
        ls = ls[1:]
        print(n.index(ls[0])+1)
2023-08-11 17:33:18
建议再看一遍题目问的是什么
2023-08-11 17:24:44
  • «
  • 1
  • »