Not able to understand the formula given in editorial

Правка en1, от shinghalrishabh, 2020-04-11 15:06:22

In english tutorial of https://mirror.codeforces.com/contest/460/problem/A, it is given that answer can be calculated using formula

/predownloaded/10/b1/10b1e92c780fc1e3547bba68ddaa8eb3e91c6576.png, but I am not able to understand how we reached at this formula. Please help me in this.

Here is my accepted submission , but my solution will exceed time limit if value of n is very large. Fortunately in this question input size limit is very small hence my solution works.

https://mirror.codeforces.com/contest/460/submission/76206660

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en5 Английский shinghalrishabh 2020-04-11 15:17:21 0 (published)
en4 Английский shinghalrishabh 2020-04-11 15:16:52 70
en3 Английский shinghalrishabh 2020-04-11 15:13:20 1 Tiny change: 'very small hence my ' -> 'very small, hence my ' (saved to drafts)
en2 Английский shinghalrishabh 2020-04-11 15:07:28 61
en1 Английский shinghalrishabh 2020-04-11 15:06:22 597 Initial revision (published)