Pro.ID22123 TitleEncryption Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22123 AC0 Submit0 Ratio- 时间&空间限制描述Let me introduce an easy method of encryption to you. Suppose there’re N bytes (1 byte = 8 bits) data that are to be encrypted and we want to encrypt them in groups of M bytes, while for the last group we may need to add some zeros to make up M bytes. Then we find out an M*M matrix (Aij) m*m. Now for each group, suppose M bytes are X1, X2, ..., Xm, and we will generate the encrypted data Y1, Y2, ..., Ym from the following equations: Yi = (X1*Ai1) + (X2*Ai2) + ... + (Xm*Aim) i = l, 2, 3, ..., m 输入There are multiple cases. For each case, there are two numbers N and M ( 1 <= N <= 100, 2 <= M <= 10 ) in the first line. In the second line are N numbers to be encrypted (between 0 and 255). While in the following if lines, each line contains M numbers and the j-th number in the i-th line of these M lines is Aij (0 <= Aij <= 255). Numbers in the same line are separated by spaces. Input will be ended by end of file. 输出Description Let me introduce an easy method of encryption to you. Suppose there’re N bytes (1 byte = 8 bits) data that are to be encrypted and we want to encrypt them in groups of M bytes, while for the last group we may need to add some zeros to make up M bytes. Then we find out an M*M matrix (Aij) m*m. Now for each group, suppose M bytes are X1, X2, ..., Xm, and we will generate the encrypted data Y1, Y2, ..., Ym from the following equations: Yi = (X1*Ai1) + (X2*Ai2) + ... + (Xm*Aim) i = l, 2, 3, ..., m Input There are multiple cases. For each case, there are two numbers N and M ( 1 <= N <= 100, 2 <= M <= 10 ) in the first line. In the second line are N numbers to be encrypted (between 0 and 255). While in the following if lines, each line contains M numbers and the j-th number in the i-th line of these M lines is Aij (0 <= Aij <= 255). Numbers in the same line are separated by spaces. Input will be ended by end of file. Output For each case, output one line of the encrypted data. If the encrypted data contains K numbers, use AM spaces to separate them. Sample Input 4 2
1 2 3 4
0 1
1 0
1 2
1
3 1
0 1
10 10
100 100 100 100 100 100 100 100 100 100
100 100 100 100 100 100 100 100 100 100
0 1 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 1 Sample Output 2 1 4 3
3 0
100000 100 100 100 100 100 100 100 100 100 Source 样例输入4 2
1 2 3 4
0 1
1 0
1 2
1
3 1
0 1
10 10
100 100 100 100 100 100 100 100 100 100
100 100 100 100 100 100 100 100 100 100
0 1 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 1 样例输出2 1 4 3
3 0
100000 100 100 100 100 100 100 100 100 100 作者 |