Комментарии
На chokudai → AtCoder Beginner Contest 178 Announcement, 6 лет назад
0

I did D using combinatorics. It is the modified version of distributing n balls into r urns such that each urn contains at least 1 ball.

Solution of standard problem: (n-1)C(r-1).

Here problem can be reformulated as if you can use any number of urns (because the length of sequence can vary) and each urn should contain at least 3 balls.

Solution: summation of (n-1-2*i)C(i-1) for all i, where i is the number of urns and n is the sum we want. The term -2*i because we first put 2 balls in every urn so that problem is now transformed into a standard one containing at least 1 balls, for each i.

https://atcoder.jp/contests/abc178/submissions/16705277