60分
  • 板块P2415 集合求和
  • 楼主QAQ5
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/7/26 08:54
  • 上次更新2024/7/26 10:11:42
查看原帖
60分
749028
QAQ5楼主2024/7/26 08:54
collect = [int(n) for n in input().split(' ')]
collectLen = len(collect)
sons = []
for length in range(1,collectLen + 1):
    idxs = [count for count in range(0,length)]
    idxsLen = len(idxs)
    iendIdx = idxsLen - 1
    currentAdd = iendIdx
    while idxs[0] < collectLen - length + 1:
        son = []
        for i in range(0,idxsLen):
            son.append(collect[idxs[i]])
        sons.append(son)
        idxs[currentAdd] += 1
        while not (idxs[currentAdd] < collectLen - (iendIdx - currentAdd)):
            if currentAdd == 0:
                break
            currentAdd -= 1
            idxs[currentAdd] += 1
            for i in range(currentAdd + 1,idxsLen):
                idxs[i] = idxs[i - 1] + 1
        currentAdd = iendIdx
total = 0
for son in sons:
    total += sum(son)
print(total)
2024/7/26 08:54
加载中...