Problem C - Digit Sums ---------------------- Given an input string of digits, the problem is to find the number of possible combinations of those digits that sum to a given value. Interpret a 0 in the string as 10. For example, there are four combinations of digits from the string 1273132012321 that sum to 37: 1 2 7 3 1 3 2 0 1 2 3 2 1 ------------------------------------- 2 +7 +3 +1 +3 +2+10 +1 +2 +3 +2 +1 = 37 1 +2 +7 +3 +3 +2+10 +1 +2 +3 +2 +1 = 37 1 +2 +7 +3 +1 +3 +2+10 +2 +3 +2 +1 = 37 1 +2 +7 +3 +1 +3 +2+10 +1 +2 +3 +2 = 37 The string 4444444441111 also has 4 combinations that sum to 37: 4 4 4 4 4 4 4 4 4 1 1 1 1 ------------------------------------- 4 +4 +4 +4 +4 +4 +4 +4 +4 +1 = 37 4 +4 +4 +4 +4 +4 +4 +4 +4 +1 = 37 4 +4 +4 +4 +4 +4 +4 +4 +4 +1 = 37 4 +4 +4 +4 +4 +4 +4 +4 +4 +1 = 37 Input Format ------------ Each line will contain a string of at most 64 digits, followed by a single space, followed by a positive integer. A line containing 0 0 indicates the end of the input. Output Format ------------- See sample output. Do not generate any output for the last line of the input Sample Input ------------ 1273132012321 37 4444444441111 37 1231678768130123 14 0 0 Sample Output ------------- String 1273132012321 has 4 combination(s) totalling 37. String 1273132012321 has 4 combination(s) totalling 37. String 4444444441111 has 4 combination(s) totalling 37. String 1231678768130123 has 402 combination(s) totalling 14.