#P2325. Persistent Numbers
Persistent Numbers
问题描述
数字的乘法持久性(Multiplicative Persistence)由 Neil Sloane(Neil J.A. Sloane 在 1973 年发表于《Journal of Recreational Mathematics》第 6 卷的论文 The Persistence of a Number 中定义)指的是将一个数的各位数字相乘,重复这一过程直到得到一个一位数所需的步数。例如:
$$679 \rightarrow 6 \times 7 \times 9 = 378 \rightarrow 3 \times 7 \times 8 = 168 \rightarrow 1 \times 6 \times 8 = 48 \rightarrow 4 \times 8 = 32 \rightarrow 3 \times 2 = 6 $$因此, 的持久性是 。一位数的持久性为 。目前已知存在持久性为 的数字,但尚未发现持久性为 的数字。如果存在这样的数字,已知其最小值的位数将超过 位。
本题的任务是:给定一个数字,找到最小的数字,使得在计算其持久性的第一步(即各位数字相乘)时得到给定的数字。如果不存在这样的数字,则输出提示信息。
输入
- 每个测试用例输入一行,包含一个最多 位的十进制数字。
- 最后一个测试用例后是一个包含 的行。
输出
- 对于每个测试用例,输出一行:
- 满足条件的最小整数,或
- 如果不存在这样的数字,输出
There is no such number.
(格式如示例所示)。
示例输入输出
输入 1:
0
1
4
7
18
49
51
768
-1
输出 1:
10
11
14
17
29
77
There is no such number.
2688