Comments
On MLA19Codeforces Round 1056 (Div. 2), 12 months ago
+2

Here is a clean brute force implementation for C

Spoiler

I am thinking a similar approach — but how to formalize space here? Initially lets say I have logn range, second time I might have logn * logn ranges... and (logn)^i ranges at ith position? Should it not explode?

You traverse the array, from 2 to n. The first index where gcd(a[i], a[i+1)<gcd(a[i], a[i-1]), you can either remove i-1, i, or i+1. You do all of it, and check if any of them gives you a favourable outcome.

I did worse :(

-7

Failed in this contest desperately (-1000 aura)

It was unrated for me (+100 aura)

Still what did I do :(

0

Start from reverse. Start from one element that is going to be remaining at last, after removing every other. Then keep multiplying second last, third last… while taking modulo. And then print array of answers in reverse