help me to understand the proof of 2137B

Revision en1, by ahnaf09, 2025-10-07 08:00:44

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!

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English ahnaf09 2025-10-07 08:04:24 7 Tiny change: 'on of the code\n#include' -> 'on of the logic\n#include'
en2 English ahnaf09 2025-10-07 08:04:03 516
en1 English ahnaf09 2025-10-07 08:00:44 1673 Initial revision (published)