COOLNUMS - Cool Numbers

no tags 

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].

Input Format:
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.

Output Format:
For each testcase print a single line containing one integer saying the number of cool numbers between A and B, inclusive.

Sample Input:
1 11
12 20
1 20
3 100
6354 234363
123456789 234567891
0 0
Sample Output:

Test Data:
About 50 testcases.

hide comments
Ricardo Oliveira [UFPR]: 2013-02-26 14:21:17

4*10^9 does not fit in a 32-bit UNsigned integer, right?

Added by:Prasanna
Time limit:5.673s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:NITT ACM ICPC Local Contest 2007 [Topcoder problem with Constraints raised]