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

Difference

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2916    Accepted Submission(s): 732


Problem Description
Little Ruins is playing a number game, first he chooses two positive integers $y$ and $K$ and calculates $f(y, K)$, here

$$f(y, K) = \sum_{z\text{ in every digits of }y} z^K (f(233, 2) = 2^2 + 3^2 + 3^2 = 22)$$

then he gets the result

$$x = f(y, K) - y$$

As Ruins is forgetful, a few seconds later, he only remembers $K$, $x$ and forgets $y$. please help him find how many $y$ satisfy $x = f(y, K) - y$.
 

Input
First line contains an integer $T$, which indicates the number of test cases.

Every test case contains one line with two integers $x$, $K$.

Limits
$1 \leq T \leq 100$
$0 \leq x \leq 10^9$
$1 \leq K \leq 9$
 

Output
For every test case, you should output 'Case #x: y', where x indicates the case number and counts from 1 and y is the result.
 

Sample Input
2 2 2 3 2
 

Sample Output
Case #1: 1 Case #2: 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-18 16:25:56, Gzip enabled