问题3783--Text Encryption

3783: Text Encryption

[命题人 : ]
时间限制 : 3.000 sec  内存限制 : 64 MB

题目描述

To keep privacy of messages and prevent the aliens from reading them, we may use variousencryption algorithms. These algorithms encode a message into the so-called ciphertext that isdifficult (or impossible) to decode for anyone else than the intended recipient. Transpositionciphers are a type of encryption that do not change the letters of the message but only changetheir order ("shuffle" the letters). Of course, the shuffling must be reversible to allow laterdecryption.In this problem, we will consider a simple transposition cipher which shuffles the letters insuch a way that the decryption algorithm always takes every n-th letter. More specifically:when decrypting, the first letter of the ciphertext is taken first, then the next n - 1 letters are(repeatedly) skipped and the next letter taken, and so on until we reach the end of the ciphertext.After that, we repeat the procedure starting with the second letter of the ciphertext, and so onuntil all letters are used.Your task is to implement the encryption algorithm for this cipher. For a given message, producethe encrypted text (ciphertext). To make the cipher a little bit stronger, you should convert allletters to uppercase and leave out all spaces between words.

输入

The input contains several messages. Each message is described by two lines. The first linecontains one integer number N (1 ≤ N ≤ 1000). The second line contains the message. Themessage will be at most 10 000 characters long, it will only contain letters and spaces, and therewill be at least one letter in each message.The last message is followed by a line containing zero

输出

For each message, output the ciphertext that, after using the described decryption algorithm,will result in the original message (with all spaces removed and all letters in uppercase).

样例输入 Copy

2
CTU Open Programming Contest
7
This is a secret message that noone should ever see Lets encrypt it
15
text too short
0

样例输出 Copy

CMTMUIONPGECNOPNRTOEGSRTA
TESNUECHCAOLERIRGODLYSEENEEPITTEVTTSMHSESIAEAHRETSSTOSN
TEXTTOOSHORT

来源/分类