当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6244:Same Digit

题目描述
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$.
输入解释
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$
输出解释
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.
输入样例
2
1 10
4 64
输出样例
Case #1: 3
Case #2: 2
提示
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6244

最后修改于 2020-10-25T23:29:38+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
40000/20000MS(Java/Others) 524288/524288K(Java/Others)