CodeAbbey/Corrections

Lucky Tickets Advanced

Closed this issue · 1 comments

This is an advanced version of the Lucky Tickets problem.

The values here are going to be slightly greater than before so that it is not possible to use direct count of sums, as you might have done before,
and a "dynamic programming" approach is more suitable.

Please note that the result could be so large that the built-in types for some languages will be unable to store it. For example, with C++ neither long long nor double will do. You may prefer to switch to Python or Java, temporarily, or implement "long arithmetic" such as using arrays to hold big integer values.

input data contains two values: N - the length of the ticket number and B - the base of numeral system.
answer should contain the amount of lucky tickets.

Note: to simplify the matter, N is always even and B do not exceed 9.

Example:

input data:
22 8

answer:
2719720106419046288

The last line should have "B does not exceed 9", not "B do not exceed 9".