#P297. 【例50.3】 平衡数
【例50.3】 平衡数
Description
A balanced number is a positive integer where each digit appears exactly times in . For example, is a balanced number because:
For the hundreds digit , the digit appears exactly time in , satisfying the condition;
For the tens digit , the digit appears exactly times in , satisfying the condition;
For the ones digit , the digit appears exactly times in , satisfying the condition;
Since every digit in satisfies the condition, is a balanced number.
Given two positive integers and (), please help calculate the sum of all balanced numbers between and .
Input Format
One line containing two positive integers and (), separated by a space.
Output Format
One line containing a single integer, representing the sum of all balanced numbers between and .
Sample
1 2523
Related
In following homework: