【題解】ZeroJudge c134: 00668 – Parliament

【題目敘述】https://zerojudge.tw/ShowProblem?problemid=c134

n = int(input())
for i in range(n):
    string = input()
    num = int(input())
    j = 1
    lst = []
    while True:
        j += 1
        if num == j:
            num -= j
            lst.append(j)
            break
        elif num == j-1:
            for k in range(0, j-2):
                lst[k] += 1
            lst[-1] += 1
            break
        elif num < j:
            for k in range(-1, -1-num, -1):
                lst[k] += 1
            break
        num -= j
        lst.append(j)
    print(' '.join([str(num) for num in lst]))
分享本文 Share with friends