Problem 3953 · Hard

Maximum Score with Co-Prime Element

Try each index and each final value, pay one change for each neighbour that shares a factor, and keep the best value minus cost.

Open the interactive visualisation