F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Counting problem

Time 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
1 1 1 1 1 10 2 1
 

Sample Output
1 2
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-26 05:42:33, Gzip enabled