|
||||||||||
Counting problemTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 809 Accepted Submission(s): 200 Problem Description Supose that n has L digits, we used $d_0, d_1, d_2, \ldots, d_{L-1}$ to indicate every digit of n from least significant digit to most significant one. $f(n, k) = \sum\limits_{i=0}^{L-1}d_i^k$, for example $f(305, 2) = 5^2 + 3^2 + 0^2 = 34$ We are curious about that for each x ranged from a to b($a \leq b$), how many integers make $S=f(x, k)$ (here S is a constant) true. Input Multi test cases (about 100), every case gives four integers a, b, k, S in a single line. Please process to the end of file. [Technical Specification] $1 \leq a \leq b \leq 999999999$ $1 \leq k \leq 15$ $1 \leq S \leq 10^{16}$ Output For each case£Ĵoutput a number in a single line indicates how many x ranged from a to b makes $S=f(x, k)$ true. Sample Input
Sample Output
Source | ||||||||||
|