主页
题目
状态
排名
OI排名
统计
题解
请登录
常用链接
AOJ考试平台
老赵的Gitee代码
编译原理模拟考试平台
Java技术手册
FCC网站
菜鸟网
在线工具箱
字节豆包GPT
代码可视化
力扣网
牛客网
洛谷
杭电OJ
CodeForce
隐藏编译器
Problem B: 火星人
上一题
正确率: $80.00\%$
下一题
Time Limit
$1$ 秒/Second(s)
Memory Limit
$512$ 兆字节/Megabyte(s)
提交总数
$5$
正确数量
$4$
"
裁判形式
标准裁判/Standard Judge
我的状态
尚未尝试
难度
分类标签
递归
×
为本题添加算法分类(请不要超过5个)
当前分类(单击移除):
递归
单击选择分类:
Description
<p><style type="text/css">p { margin-bottom: 0.21cm; }</style> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;">人类终于登上了火星的土地并且见到了神秘的火星人。人类和火星人都无法理解对方的语言,但是我们的科学家发明了一种用数字交流的方法。这种交流方法是这样的,首先,火星人把一个非常大的数字告诉人类科学家,科学家破解这个数字的含义后,再把一个很小的数字加到这个大数上面,把结果告诉火星人,作为人类的回答。</p> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;">火星人用一种非常简单的方式来表示数字——掰手指。火星人只有一只手,但这只手上有成千上万的手指,这些手指排成一列,分别编号为<font face="DejaVu Serif, serif">1</font>,<font face="DejaVu Serif, serif">2</font>,<font face="DejaVu Serif, serif">3……</font>。火星人的任意两根手指都能随意交换位置,他们就是通过这方法计数的。</p> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;">一个火星人用一个人类的手演示了如何用手指计数。如果把五根手指——拇指、食指、中指、无名指和小指分别编号为<font face="DejaVu Serif, serif">1</font>,<font face="DejaVu Serif, serif">2</font>,<font face="DejaVu Serif, serif">3</font>,<font face="DejaVu Serif, serif">4</font>和<font face="DejaVu Serif, serif">5</font>,当它们按正常顺序排列时,形成了<font face="DejaVu Serif, serif">5</font>位数<font face="DejaVu Serif, serif">12345</font>,当你交换无名指和小指的位置时,会形成<font face="DejaVu Serif, serif">5</font>位数<font face="DejaVu Serif, serif">12354</font>,当你把五个手指的顺序完全颠倒时,会形成<font face="DejaVu Serif, serif">54321</font>,在所有能够形成的<font face="DejaVu Serif, serif">120</font>个<font face="DejaVu Serif, serif">5</font>位数中,<font face="DejaVu Serif, serif">12345</font>最小,它表示<font face="DejaVu Serif, serif">1</font>;<font face="DejaVu Serif, serif">12354</font>第二小,它表示<font face="DejaVu Serif, serif">2</font>;<font face="DejaVu Serif, serif">54321</font>最大,它表示<font face="DejaVu Serif, serif">120</font>。下表展示了只有<font face="DejaVu Serif, serif">3</font>根手指时能够形成的<font face="DejaVu Serif, serif">6</font>个<font face="DejaVu Serif, serif">3</font>位数和它们代表的数字:</p> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;">三进制数</p> <p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">123</font></p> <p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">132</font></p> <p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">213</font></p> <p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">231</font></p> <p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">312</font></p> <p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">321</font></p> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;">代表的数字</p> <p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1</font></p> <p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2</font></p> <p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">3</font></p> <p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">4</font></p> <p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">5</font></p> <p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">6</font></p> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;">现在你有幸成为了第一个和火星人交流的地球人。一个火星人会让你看他的手指,科学家会告诉你要加上去的很小的数。你的任务是,把火星人用手指表示的数与科学家告诉你的数相加,并根据相加的结果改变火星人手指的排列顺序。输入数据保证这个结果不会超出火星人手指能表示的范围。</p> </p>
Input
<p><style type="text/css">p { margin-bottom: 0.21cm; }</style> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;">输入文件<font face="DejaVu Serif, serif">martian.in</font>包括三行,第一行有一个正整数<font face="DejaVu Serif, serif">N</font>,表示火星人手指的数目(<font face="DejaVu Serif, serif">1 <= N <= 10000</font>)。第二行是一个正整数<font face="DejaVu Serif, serif">M</font>,表示要加上去的小整数(<font face="DejaVu Serif, serif">1 <= M <= 100</font>)。下一行是<font face="DejaVu Serif, serif">1</font>到<font face="DejaVu Serif, serif">N</font>这<font face="DejaVu Serif, serif">N</font>个整数的一个排列,用空格隔开,表示火星人手指的排列顺序。</p> </p>
Output
<p><style type="text/css">p { margin-bottom: 0.21cm; }</style> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;">输出文件<font face="DejaVu Serif, serif">martian.out</font>只有一行,这一行含有<font face="DejaVu Serif, serif">N</font>个整数,表示改变后的火星人手指的排列顺序。每两个相邻的数中间用一个空格分开,不能有多余的空格。</p> <p style="margin-bottom: 0cm;"></p> </p>
Sample Input
复制
5 3 1 2 3 4 5
Sample Output
复制
1 2 4 5 3
提示
<p><style type="text/css">p { margin-bottom: 0.21cm; }</style> <p style="margin-bottom: 0cm;">对于<font face="DejaVu Serif, serif">30%</font>的数据,<font face="DejaVu Serif, serif">N<=15</font>;</p> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;">对于<font face="DejaVu Serif, serif">60%</font>的数据,<font face="DejaVu Serif, serif">N<=50</font>;</p> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;">对于全部的数据,<font face="DejaVu Serif, serif">N<=10000</font>;</p> </p>
AOJ
Please Login