I have a dynamic programming exercise but I dont know how it will work in here:
We have a mysterious number is a string that consists of digits and asterisk *. Given a mysterious number, count all the possible natural number to replace the asterisk * with a digit to produce an integer divisible by n. For expample:
For 1*1* and n = 6 there are 16 possible numbers divisible by n: 1014, 1110, 1116, 1212, 1218, 1314, 1410, 1416, 1512, 1518, 1614, 1710, 1716, 1812, 1818, 1914.
If there is a leading asterisk then it should never be replaced by a zero:
*12 -> 112 (is okay) but *12 -> 012 (is not okay)
Input:
1 <= inputString.size <= 1000
1 <= n <= 1000
Time limit :
500ms in C++ language. As i said this is an dynamic programming exercise.
Can anyone give me some hints on this?