SRM 467, D2, 250-Pointer (ShorterSuperSum)

James S. Plank

Tue Nov 9 17:00:53 EST 2021

In case the Topcoder servers are down

Here is a summary of the problem:

Examples

These are all included in main.cpp. If you give the input "-" to main.cpp, then it will read its values from standard input.
  #   k   n   Answer
  0   1   3       6:  1 + 2 + 3 = 6
  1   2   3      10:  SS(1,1) + SS(1,2) + SS(1,3) = 1 + 3 + 6 = 10
  2   4  10    2002
  3  10  10  167960

Testing Yourself without Topcoder's Servers

Standard workflow. See the "Cryptography" problem.

Hints

Just use a brain-dead recursion. It will finish within the time limits (on my machine, all of tests.sh takes under 2 seconds).

For a Bigger Challenge

You can increase k and n to 1,000 and use dynamic programming.