CP-2.003 - Walkthrough - Sum Kind of Problem (Kattis)

preview_player
Показать описание

The problem asks you to find the sum of a series, and I thought it's a good time to review the sum of arithmetic progressions. You can do the question with a simple loop, but in this video I worked out the formula for the sum using three different approaches.

The first approach uses the general formula for the sum of arithmetic progression. The second one is similar, but I built up the formula from scratch, which makes it very messy and cumbersome, but I hope you can see the general strategy (work from partial sum to find the actual sum). The third one is the best approach, but that comes with recognising the series.

Video Sections:
0:00 - Problem description
1:12 - First solution (use the formula for arithmetic progression)
7:40 - Second solution (build the formula from scratch)
20:21 - Third solution (recognise the series)

Please note that all views and opinions expressed in this video are my own and does not reflect that of Kattis or any other person/organisation mentioned in the video.
Рекомендации по теме