#K51967. K-Hop String Transformation
K-Hop String Transformation
K-Hop String Transformation
You are given a string S
consisting of uppercase English letters and an integer K
. Your task is to perform a K-hop transformation on the string. In a K-hop transformation, each character in S
is shifted forward by K
positions in the alphabet in a cyclic manner. Formally, each character c
is transformed as follows:
$$ c' = \text{chr}(((\text{ord}(c)-\text{ord}('A') + K) \mod 26) + \text{ord}('A')) $$
For instance, if S = "XYZ"
and K = 3
, the transformed string is "ABC"
because after Z
the alphabet wraps back to A
.
Note that if K
is larger than 26, you should use the effective shift K % 26
to perform the transformation.
inputFormat
The input consists of two lines:
- The first line contains the string
S
(only uppercase alphabets, without spaces). - The second line contains the integer
K
.
outputFormat
Output a single line containing the transformed string after performing the K-hop transformation.
## sampleHELLO
1
IFMMP