2646. Product-Sum

单点时限: 2.0 sec

内存限制: 256 MB

Recently Dr. Imo is doing some research on integral numbers. Studies of splitting numbers is especially all the zeal for him. Now, he wants you to solve one problem and to sympathize with him that they are interesting.

The problem is what is the minimum number that meets the following requirements.

  • It is an even-digit number, and it has no leading zeroes.
  • On splitting the number into two numbers which have same digits, the product of them minus the sum of them equals N.

If you are given N = 10, the answer is not 0212 (this contains leading zeroes, so it does not meet the above requirements), but 1202 ((12 × 02)-(12 + 02) = 10) is correct.

输入格式

The input is a sequence of lines each of which contains one integer N. This satisfies the following conditions.

0 < N < 1, 000, 000, 000

The end of the input is indicated by a line containing a zero.

输出格式

The output should be comprised of lines each of which contains a single integer, that is the minimum number which meets all the requirements.

The output must be written to standard output.

样例

Input
1
10
1000
0
Output
23
1202
1292

3 人解决,7 人已尝试。

3 份提交通过,共有 13 份提交。

8.7 EMB 奖励。

创建: 10 年,12 月前.

修改: 2 年,11 月前.

最后提交: 2 年,2 月前.

来源: The 1st Imos Contest

题目标签