TopcoderArchive
Archive
Algorithm problem

TheLuckyNumbersLevelThree

Problem statement, definition, constraints, and public examples.

Problem Statement

The digits 4 and 7 are lucky digits, and all other digits are unlucky. A third level lucky number is a positive integer that is divisible by at least one lucky digit. John and Brus have written down all the third level lucky numbers between a and b, inclusive, and now they would like to count the number of occurrences of each digit between 0 and 9, inclusive, in the numbers they have written.

Return a long[] containing exactly 10 elements, where the i-th element (0-based) is the total number of occurrences of digit i.

Definition

Class:
TheLuckyNumbersLevelThree
Method:
find
Parameters:
long, long
Returns:
long[]
Method signature:
long[] find(long a, long b)
(be sure your method is public)

Constraints

  • a will be between 1 and 10^16, inclusive.
  • b will be between a and 10^16, inclusive.

Examples

  1. 1
    10
    Returns: {0, 0, 0, 0, 1, 0, 0, 1, 1, 0 }
    There are three third level lucky numbers in this range - 4, 7, 8.
  2. 78
    79
    Returns: {0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
    No third level lucky numbers here.
  3. 1
    47
    Returns: {2, 4, 7, 3, 7, 1, 2, 1, 2, 0 }
  4. 21
    91
    Returns: {4, 2, 7, 4, 9, 3, 7, 5, 7, 2 }
Back to all problems