ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1082. Gaby Ivanushka

Hint
Posted by GeekCmore 10 Dec 2022 19:20
Just think of an increasing sequence. The program caculates n+1 times for an increasing sequence with n elements. And then divide it into two subsequences. One is the leftmost element, and anthoer is the left elements. It ends at the length of sequence is 2. Thus, the sum is (n+1) + n + (n-1) + ... + 3 = (n+4)(n-1)/2 = (n*n + 3*n - 4)/2. So output 1 to n is ok.