DCP-41: Innovative Birthday Gift! Back to All Problems

Easy Math > Number Theory


Tom and Jerry are not just any normal boys like others in their class. They are the best programmers in their class. Today is their birthday. So Mike decided to gift something on their birthday. As they happen to be well known programmers, Mike thought of something innovative. He sent an encrypted message to them in which the instruction for finding the gift has been written. If they desire to get their birthday gift, they have to decode the message given in the message and follow the instructions given in the message. The nature of encryption is described below: Prime numbers the positive integers which are only divisible by 1 and surely, number itself. The first of this kind is 2, then comes 3, 5, 7….. and so on. The ith letter of the original message is represented by a number ai. Let *m* is the nearest prime number less than or equal to *ai*. Now if *m* is the *r* th prime (like 2 is the 1st prime, 3 is the 2nd prime), the decoded letter would be ((*r* modulo 26)+1) th lowercase letter in the alphabet. A ‘0’ represents a space (' ') and '-1' represents a period ('.'). For example, let the encoded message contains three numbers like 12 17 -1. The nearest prime less than or equal to 12 is 11. 11 is the 5th prime. (5 modulo 26)+1=6. The 6th letter is ‘f’. Similarly 17 is the 7th prime and (7 modulo 26)+1=8. So the letter is ‘h’. Therefore, the decoded message for the sequence ‘12 17 -1’ represents “fh.”. You need to decode the message and help them get their birthday gift. Input: ------ The first line of input contains *t*, the number of test cases (1<=*t*<=10). For each of next *t* cases, there is a number *n* (1<=*n*<=100) which is followed by *n* space separated integers ai (-1<=*ai*<10000). Output: ------- Print the decrypted messages in separate lines. Sample Input ------------ 2 18 3324 0 6791 7741 3798 6883 8161 0 1873 3254 6302 373 7688 0 7151 7229 6842 -1 13 8707 7452 19 1224 0 3182 9161 0 8804 4391 5867 5280 -1 Sample Output ------------- a quick brown fox. this is easy.


Problem Setter:

Mehedi Hasan Muaz

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.00
C++ 1.00
C++14 1.00
C# 1.00
Go 1.00
Java 1.00
JavaScript 1.00
Objective-C 1.00
Perl 1.00
PHP 1.00
Python 1.00
Python3 1.00
Ruby 1.00
VB.Net 1.00

Problem Stats

137/170

Solve/Submission

Ranking

# User Language Timing
01 MAHRahat Cpp14 0.00s
02 pulak_ict_mbstu Cpp 0.00s
03 feodorv C 0.00s
04 mahbub07 Cpp14 0.00s
05 Not_Found0001 Cpp 0.00s
06 monir769 Cpp 0.00s
07 sadia2427 Cpp14 0.00s
08 mamun02inf Cpp14 0.00s
09 twyu0721 C 0.00s
10 wayne6172 C 0.00s
11 souravahmed C 0.00s
12 Robbinb1993 Cpp 0.01s
13 muntasir10mu Cpp 0.01s
14 SugiuraAyano C 0.01s
15 Logic_Hunter Cpp 0.01s
16 Morass Cpp14 0.01s
17 mahmud2690 Cpp14 0.01s
18 abdulmukit Cpp 0.01s
19 SakibAlamin Cpp14 0.01s
20 nazmul_bzs Cpp14 0.01s
21 mir003 Cpp14 0.01s
22 afzalul Cpp 0.01s
23 anik_JU Cpp14 0.01s
24 Ansarul_14 Cpp14 0.01s
25 Dinar Cpp14 0.01s
26 aseem_cu Cpp 0.01s
27 emrul Cpp14 0.01s
28 Taj025 CSharp 0.02s
29 nafischonchol Cpp 0.02s
30 mash02 Cpp 0.05s
31 celeste871103 C 0.06s
32 masba Python 0.07s
33 Najat Cpp14 0.07s
34 anis Cpp14 0.07s
35 Md_Abid Cpp14 0.09s
36 RandyWaterhouse Python3 0.16s
37 zifan Cpp14 0.22s
38 khayrul Cpp14 0.25s
39 Gias_uddin Cpp14 0.26s
40 abinash Cpp14 0.27s
41 mtmohim Cpp14 0.28s
42 Anik7703 Cpp14 0.31s
43 talha629 Cpp14 0.32s
44 mamun4122 Cpp14 0.34s
45 bhadra Cpp14 0.40s
46 kanon2 Cpp14 0.40s
47 shaheen_bd Cpp14 0.40s
48 Unseen Cpp14 0.40s
49 howcum Cpp14 0.40s
50 sajal_khan Cpp14 0.40s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support