practivceAlgorithm/swexpertacademy

[SWEA][Python] 5120 암호

findTheValue 2021. 8. 24. 00:38

i인덱스 컨트롤 해주면서 삽입

 

for test in range(1,int(input())+1):
    N, M, K = map(int, input().split())
    arr = list(map(int, input().split()))
    i = M
    for _ in range(K):
        i %= N
        if not i:
            arr.append(arr[-1]+arr[0])
            i -= 1
        else:
            arr.insert(i,arr[i-1]+arr[i])
        N += 1
        i += M
    print(f'#{test}', end=' ')
    print(*arr[-10:][::-1])

'practivceAlgorithm > swexpertacademy' 카테고리의 다른 글

[SWEA][Python] 5174 subtree  (0) 2021.08.24
[SWEA][Python] 5122 수열편집  (0) 2021.08.24
[SWEA][Python] 5110 수열 합치기  (0) 2021.08.24
[SWEA][Python] 5108 숫자추가  (0) 2021.08.24
[SWEA][Python] 4874 Forth  (0) 2021.08.20