求最优解法

WillWinwin 2014-02-28 03:56:24
Description
Mo and Larry have devised a way of encrypting messages. They first decide secretly on the number of columns and write the message (letters only) down the columns, padding with extra random letters so as to make a rectangular array of letters. For example, if the message is "There's no place like home on a snowy night" and there are five columns, Mo would write down t o i o y h p k n n e l e a i r a h s g e c o n h s e m o t n l e w x Note that Mo includes only letters and writes them all in lower case. In this example, Mo used the character `x' to pad the message out to make a rectangle, although he could have used any letter. Mo then sends the message to Larry by writing the letters in each row, alternating left-to-right and right-to-left. So, the above would be encrypted as toioynnkpheleaigshareconhtomesnlewx Your job is to recover for Larry the original message (along with any extra padding letters) from the encrypted one.

Input
There will be multiple input sets. Input for each set will consist of two lines. The first line will contain an integer in the range 2 . ..20 indicating the number of columns used. The next line is a string of up to 200 lower case letters. The last input set is followed by a line containing a single 0, indicating end of input.

Output
Each input set should generate one line of output, giving the original plaintext message, with no spaces.

Sample Input
Copy sample input to clipboard
5
toioynnkpheleaigshareconhtomesnlewx
3
ttyohhieneesiaabss
0
Sample Output
theresnoplacelikehomeonasnowynightx
thisistheeasyoneab
...全文
239 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
shiguojie19892 2014-03-06
  • 打赏
  • 举报
回复
引用 5 楼 u013816144 的回复:
引用 1 楼 shiguojie19892 的回复:
你来考托福?
你有最优解吗
我没有看懂是什么,给翻译一下?
WillWinwin 2014-03-03
  • 打赏
  • 举报
回复
引用 2 楼 truelance 的回复:
又一个自己不懂脑子的娃
好吧,我也呵呵
WillWinwin 2014-03-03
  • 打赏
  • 举报
回复
引用 1 楼 shiguojie19892 的回复:
你来考托福?
你有最优解吗
WillWinwin 2014-03-03
  • 打赏
  • 举报
回复
引用 1 楼 shiguojie19892 的回复:
你来考托福?
你想多了
熊熊大叔 2014-03-01
  • 打赏
  • 举报
回复
又一个自己不懂脑子的娃
fx_is_vincent 2014-03-01
  • 打赏
  • 举报
回复
呵呵~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shiguojie19892 2014-02-28
  • 打赏
  • 举报
回复
你来考托福?

64,642

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧