QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 128 MB 總分: 100

#4847. Kreditna

统计

作为一名常旅客俱乐部的成员,Marko 积累了许多奖励里程,并最终决定奖励自己去澳大利亚旅行。然而,正如通常发生的那样,奖励里程并不能覆盖所有的旅行费用,因此航空公司的一位先生在电话中要求 Marko 通过电子邮件发送他的信用卡号(一个由 16 位数字组成的序列)。

Marko 意识到这很疯狂,但电话那头的先生坚持要这样做。作为妥协,Marko 提议发送一个通过以下算法加密后的卡号:

  • Marko 将找到数字中最小的数字,如果有多个,他将选择从左起第一个。我们将这个数字称为 $A$。
  • 然后,他将找到数字中最大的数字,如果有多个,他将选择从右起最后一个。我们将这个数字称为 $B$。
  • 将数字 $A$ 加 1,除非它已经是 9。
  • 将数字 $B$ 减 1,除非它已经是 0。
  • 最后,Marko 将数字 $A$ 和 $B$ 的位置互换。

例如,如果他的卡号是 7691 0027 7960 3269,那么 Marko 在电子邮件中发送的数字将是:7691 8027 7960 3261

请编写一个程序,帮助航空公司的那位先生确定 Marko 的原始信用卡号。

输入格式

第一行也是唯一一行包含一个由 16 位数字 '0' - '9' 组成的序列,即 Marko 在电子邮件中发送的数字。

说明:信用卡号可以以数字 '0' 开头。

输出格式

输出所有可能的 Marko 的原始信用卡号,每行一个。

如果不存在任何有效的信用卡号,请输出 “banana”。

样例

输入 1

7691802779603261

输出 1

7691002779603269

输入 2

8381950005575690

输出 2

banana

输入 3

8446462287549826

输出 3

1446462287549896
8446462217549896
8446462287549196

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.