Shift Password time limit: +Ms | Memory Limit:65535KB Difficulty:0
-
-
Describe
-
Shift cipher is the simplest kind of substitution password, the specific algorithm is to move the letter of the alphabet to the right of the K-position (k<26), and the length of the alphabet as a modulo operation.
Now give you a bunch of ciphertext, all made up of uppercase letters. It is known that the encryption process is: Move each letter to the right by the alphabetical order of k bits.
Cryptographic functions: E (m) = (m+k)%q.
Please decipher the clear text!
-
-
Input
-
The
-
input contains multiple sets of test data (less than 1000 groups).
Each set of data contains a string and an integer k (k<26), separated by a space, the string is all composed of uppercase letters, the length is less than 50,k to the right to move the number of digits.
-
-
Output
-
-
outputs the plaintext corresponding to each set of ciphertext, one row for each set of outputs.
-
-
Sample input
-
-
JMPWFZPV 1
-
-
Sample output
-
-
ILOVEYOU
-
-
Source
Password series
#include <stdio.h> #include <string.h>int main () {int K;char str[55];while (~scanf ("%s", str)) {int len= strlen (str), i;scanf ("%d", &k), for (i=0;i<len;++i) {printf ("%c", (str[i]-' a '-k+26)%26+ ' a ');} printf ("\ n");} return 0;}
nyoj-Shift Password