201803-2(Python实现)

2019-12-09  本文已影响0人  tmax
n, L, t = list( map(int, input().split()) )
tmpList = list(map(int, input().split()) )
sortedTmpList = sorted(tmpList)
posList = [0] + sortedTmpList
referList = []
for ele in tmpList:
    for i in range(len(sortedTmpList)):
        if ele == sortedTmpList[i]:
            referList.append(i)
            break
direList = [1]*(n+1)

for i in range(1, t+1):
    for j in range(1, n+1):
        posList[j] += direList[j]*1
        if posList[j] > L:
            posList[j] = 2*L - posList[j]
            direList[j] *= -1
        if posList[j] < 0:
            posList[j] = -posList[j]
            direList[j] *= -1
    for j in range(1, n):
        if posList[j]==posList[j+1] and direList[j]==-direList[j+1]:
            direList[j] *= -1
            direList[j+1] *= -1

for idx in referList:
    print(posList[idx+1],end=' ')
                
上一篇下一篇

猜你喜欢

热点阅读