Cyberland vs Byteland
All submissions for this problem are available.
The king of Cyberland always envied the great Emperor of Byteland , whose court was studded with wonderful gems. The king of Cyberland knew it very well that Chef was unparallel to his brilliance and that he is out to represent Byteland at Poland for world finals. He thought this is a good chance to show Emperor of Byteland down and at once sent a messenger with a card and a letter. The card carried two strings D and K with a hint in the end.
Hint:- Original string has been encrypted using the key K by the beauty of the string. Beauty of a string is calculated by assigning value to every letter in the string lexicographically in a particular direction.
The letter read , “I’ve heard a lot about your wise courtiers. In the card I have given you two strings and a hint. Decrypt the first string with the help of second. This is a challenge.”
Since Chef is out to represent Byte land in Poland for ICPC finals. The Emperor assigned the responsibility of solving this puzzle to you.
The first line has an integer T denoting the number of test cases. T test cases follow.Each test case consists of two lines. First lines contain the string D and second line contains the string K.
For each line output the decrypted string.
1 ≤ T ≤ 300000 (3 * 105)
1 ≤ D < 429496729
1 ≤ K ≤ D
Input: 1 oorrfifdttmefreershuncoadCgeo birthday
Example case 1.
Beauty of ‘birthday’=28347651 2-->2nd letter+10th letter +18th letter + 26th letter=oorr 8-->8th letter + 16th letter + 24th letter=fif . . . . 1-->1st letter + 9th letter + 17th letter + 25th letter =Cgeo Now putting the letters in their original position i.e. 1st 2nd 3rd ....... --> Codechefgotfouriertransformed
|Time Limit:||5 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.