COOLNUMS - Cool Numbers
Cool numbers are those, whose digits can be partitioned into two sets such that the sum of the digits in either sets are equal.
Example: 23450 is cool because 3+4+0 = 2+5; So is 91125;
The numbers 567, 34523 are not cool, since there is no such digit partition.
Write a program that prints the number of cool numbers in the inclusive range [A,B].
The input file consists of multiple testcases.
Each case contains one line containing two 32-bit unsigned integers A and B. (1 <= A <= B <= 4*109).
Input terminates with a line containing two zeros and must not be processed.
For each testcase print a single line containing one integer saying the number of cool numbers between A and B, inclusive.
1 11 12 20 1 20 3 100 6354 234363 123456789 234567891 0 0Sample Output:
1 0 1 9 82340 54801678
About 50 testcases.
Ricardo Oliveira [UFPR]:
4*10^9 does not fit in a 32-bit UNsigned integer, right?