A1295 | [COCI-2013_2014-contest2]#5 SLOM
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Little Marin spent all his day generating test data for COCI. He simply couldn't make it work, so he had a nervous breakdown and can't even see clearly anymore. Every time he blinks while reading, the letters in a word get mixed up so that the letters from the second half of the word (the shorter half, if the length is an odd number) "jump in" between the letters from the first half in the following way:
• the last letter "jumps in" between the first and the second letter
• the penultimate letter "jumps in" between the second and the third letter
• the k th letter from the end "jumps in" between the k th and the (k+1)
th letter from the beginning For example, the word "abcdef" would become "afbecd" after blinking.
If Marin blinks again, the same thing happens. After two blinks, the word "abcdef" becomes "adfcbe".
Marin has decided to write a program to help him determine what's exactly written on the screen.
Unfortunately, after a day's work, he's simply too tired and he needs your help. You are given X, the number of blinks, and the word Marin sees on the screen. Write a program to solve the mystery for Marin and determine what was actually the word before he blinked X times.
• the last letter "jumps in" between the first and the second letter
• the penultimate letter "jumps in" between the second and the third letter
• the k th letter from the end "jumps in" between the k th and the (k+1)
th letter from the beginning For example, the word "abcdef" would become "afbecd" after blinking.
If Marin blinks again, the same thing happens. After two blinks, the word "abcdef" becomes "adfcbe".
Marin has decided to write a program to help him determine what's exactly written on the screen.
Unfortunately, after a day's work, he's simply too tired and he needs your help. You are given X, the number of blinks, and the word Marin sees on the screen. Write a program to solve the mystery for Marin and determine what was actually the word before he blinked X times.
输入格式
The first line of input contains a positive integer X (1 ≤ X ≤ 1 000 000 000), the number of times Marin blinked.
The second line of input contains the word from the screen, its length being from the interval [3, 1000].
The word will consist only from small letters of English alphabet.
The second line of input contains the word from the screen, its length being from the interval [3, 1000].
The word will consist only from small letters of English alphabet.
输出格式
The first and only line of output must contain the original word, before Marin blinked X times.
输入输出样例
输入 #1
4 acefdb
输出 #1
abcdef
输入 #2
1000 aaaaaa
输出 #2
aaaaaa
输入 #3
11 srama
输出 #3
sarma
In test data worth 50 points, X will be smaller than or equal to 100.
Clarification of the first example: The word gets altered in the following order: abcdef, afbecd,
adfcbe, aedbfc, acefdb.
Clarification of the first example: The word gets altered in the following order: abcdef, afbecd,
adfcbe, aedbfc, acefdb.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted