Lucky Tickets Advanced
This is an advanced version of the Lucky Tickets problem.
Values here are going to be slightly greater so that it is not possible to use direct count of sums as you probably did and some "dynamic programming" approach should be invented.
doublewill do. You may prefer to switch to
Javatemporarily, or implement "long arithmetics" representing values as arrays in such case.
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
input data: 22 8 answer: 2719720106419046288