📌  相关文章
📜  在线将python转换为c++ - Python代码示例

📅  最后修改于: 2022-03-11 14:46:19.832000             🧑  作者: Mango

代码示例10
def create(n):
    l = []
    for i in range(1, n+1):
        l.append(i)
    return l
    
def operation(n ,p):
    l = []
    kl = []
    if p < n-1:
        return kl
    t = 0
    c = 1
    for i in range(n-1, 0, -1):
        c += 1
        if t+c+i-1 >= p:
            r = p-t-i+1
            l.append(r)
            for k in range(i-1):
                l.append(1)
            t = p
            break
        t += c
        l.append(c)
    if t < p:
        return k1
    return l
    
def operate(l ,ope):
    length = len(ope)
    for i in range(elngth):
        t = len(l) - (i+2)
        sp = t + ope[i]
        l = l[:t] + list(reversed(l[t:sp])) + l[sp:]
    return l

def main():
        inp = input().split()
        n = int(inp[0])
        p = int(inp[1])
        l = create(n)
        ope = operation(n, p)
        l = operate(l, ope)
        result = " "
        
        if ope:
            for item in l:
                result += str(item) + " "
            else
                result = "IMPOSSIBLE"
        print(f'Case # {str(i+1)} : {str(result)}')    

for i in range(int(input())):
    main()