DP on Amount x Remainder (100x50), then continusously subtract calculated amounts with 1... 2... 3... from given index. Once it becomes strictly less than current number - proceed deeper for the next value.
N is much smaller than 50^100. 50^100 - is the number of all possible states, but N is the order of all ALLOWABLE states (whose sum mod K = 0 )and that's quite less, but still does not fit even in int64 :(. Wherefore, you have to use long arifmetics.
If you have got WA on Test #5, just pay attention to the statement of the problem. It is said that N is "an arbitrary vector of length L" in the problem, but actually N is just an INTEGER. So, read an integer instead of reading a string with length L.