Same Digit

TimeLimit:20000MS  MemoryLimit:524288KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
Little Mono is a smart child, he can do complex arithmetical operations quickly. But he only knows one digit $D(1 \leq D \leq 9)$. He would like to use the only digit he knows to make expressions to represent integer numbers.
A valid expression can be generated like this:
1. Any number consists of only digit $D$ are valid expressions. E.g. if $D = 1$, then 1, 11, 111, ... are all valid expressions.
2. If $A$ and $B$ are valid expressions, then $(A) + (B)$ is a valid expression.
3. If $A$ and $B$ are valid expressions, then $(A) - (B)$ is a valid expression.
4. If $A$ and $B$ are valid expressions, then $(A) * (B)$ is a valid expression.
5. If $A$ and $B$ are valid expressions, then $(A)/(B)$ is a valid expression. (/ here produces exact value, not integer division)
6. If $A$ and $B$ are valid expressions, then $(A)^{(B)}$ is a valid expression.
7. If $A$ is valid expression, then $\sqrt{A}$ is a valid expression.
8. If $A$ is valid expression, then $(A)!$ is a valid expression.(! here means factorial, and expression $A$ must produce a non-negative integer)
Now Little Mono would like to know the minimal number of $D$s he needs to use in order to represent integer $N$.
Input
The first line of the input gives the number of test cases, $T$. $T$ test cases follow.
Each test case contains one line consists of 2 integers $D$, $N$, indicating the digit Little Mono knows and the integer Little Mono would like to represent.
$1 \leq T \leq 100$
$1 \leq D \leq 9$
$1 \leq N \leq 200$
Output
For each test case, output one line containing “Case #x: y”, where $x$ is the test case number (starting from 1) and $y$ is the minimal number of $D$s Little Mono has to use.
SampleInput
2
1 10
4 64
SampleOutput
Case #1: 3
Case #2: 2
 Hint
Submit
题目统计信息详细
总AC数0
通过人数0
尝试人数0
总提交量0
AC率0.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签
出处

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: