nyoj-Shift Password

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.