Skip to content

Commit

Permalink
Assembly via Remainders
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Pandey20 committed May 13, 2024
1 parent 00522d7 commit 1d9d3f0
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions 1968C.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
t = int(input())
outs = []


for tt in range(t):
n = int(input())
x = list(map(int, input().split()))

a = [0]*n

a[0] = x[0]+1
for i in range(1, n-1):
if a[i-1]>x[i-1] and x[i-1]!=1 and x[i-1]>x[i]:
a[i]=x[i-1]
else:
mul = x[i]//a[i-1]
if a[i-1]*mul + x[i-1]>x[i]:
a[i] = mul*a[i-1]+x[i-1]
else:
a[i] = (mul+1)*a[i-1]+x[i-1]

a[-1] = x[-1]

outs.append(a)

for out in outs:
print(*out)

0 comments on commit 1d9d3f0

Please sign in to comment.