#P5842. Blinker's Admirers' Special Numbers

    ID: 19070 Type: Default 1000ms 256MiB

Blinker's Admirers' Special Numbers

Blinker's Admirers' Special Numbers

Blinker has numerous admirers, each assigned a positive integer as an ID. The significance of an admirer is defined by the product of the digits of their ID. Formally, for a number \(n\) with digits \(d_1,d_2,\dots,d_m\), its significance is given by:

[ \textrm{significance}(n) = d_1\times d_2\times \cdots \times d_m ]

Given three integers \(A\), \(B\) and \(K\), your task is to compute the sum of all admirer IDs \(n\) such that \(A \le n \le B\) and \(\textrm{significance}(n)=K\). For example, if \(K=8\), then admirer ID 8 (since \(8=8\)) and 18 (since \(1\times8=8\)) are counted.

inputFormat

The input consists of a single line containing three space-separated integers: \(A\), \(B\) and \(K\).

\(A\) and \(B\) denote the inclusive range of admirer IDs, and \(K\) is the target significance value.

outputFormat

Output a single integer which is the sum of all admirer IDs within the range \([A, B]\) whose significance (the product of their digits) equals \(K\).

sample

1 20 8
26