QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 2048 MB 總分: 100

#2227. 无器官的人

统计

每隔一段时间,就会有一批通用机器人从地球运往火星,以协助你完成日常的殖民任务。这些机器人被称为“无器官人”(Organ-free Men,确切地说是 OFMv5001.41.912),每一个机器人都有一个唯一的序列号,该序列号是一个正整数。

为了防止太空盗窃,OFM 在从地球运往火星时处于锁定状态,必须先通过一个特殊的密码解锁。解锁 OFM 的密码基于其序列号和一个函数 $f(x)$。函数 $f(x)$ 定义如下:

如果 $0 \le x \le 9$,则 $f(x) = x!$;如果 $x > 9$,则 $f(x) = (x \bmod 10)! + f(\lfloor x/10 \rfloor)$。括号 $\lfloor \rfloor$ 表示向下取整(例如 $\lfloor 2.43 \rfloor = 2$)。感叹号表示阶乘,即对于 $x > 0$,$x! = 1 \times 2 \times \dots \times x$,且 $0! = 1$。

要解锁序列号为 $y$ 的 OFM,你需要输入最小的非负整数 $x$,使得 $f(x) = y$ 成立。

你能成功解锁所有运送给你的机器人吗?

输入包含一个整数 $y$ ($1 \le y \le 10^9$),即特定 OFM 的序列号。

输出一个非负整数 $x$,即解锁该特定 OFM 的密码。

样例

输入格式 1

3

输出格式 1

12

输入格式 2

20

输出格式 2

2333

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.