Hello everyone,
I’m currently stuck on a Codeforces problem — Problem 2137B. While reading the official editorial, I got confused about one particular transformation step:
Each element is replaced by
n + 1 - p[i].
I understand the use of n + 1, since we’re working with adjacent elements and need a length of n + 1. However, I don’t quite understand why we subtract p[i].
Also, I noticed that the editorial mentions a condition like: G C D ( p i + q i , p i + 1 + q i + 1 ) ≥ 3
I’m wondering if this relates to the property gcd(a, b) = gcd(a - b, b) where (a > b). Is that property being applied here?
And finally, does the condition hold simply because (n > 3) (since (n + 1 > 3)) — or is there a deeper reason behind it?
I’d really appreciate it if someone could explain this step more clearly. I’m still a beginner, so a simple explanation would be very helpful.
Thank you in advance!



