Help understand the solution of round 257 (div 1 D) — Jzzhu and Numbers

Правка en1, от Wildebeest, 2017-05-23 09:40:21

I was trying to solve this problem for several days. I failed and read the editorial. But I couldn't understand the solution. Can someone please explain how they came up with that formula?

Thanks in advance :)

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Wildebeest 2017-05-23 09:40:21 375 Initial revision (published)