DCP-316: Names Back to All Problems

Easy Math > Counting


We know that **Mr. Royel** is the oldest man and his family is the biggest family in the world. So, he faces a problem to find names for new family member. That's why he comes to you, and you have to help him. You are given the length of names **L** and a string **S**. You have to find the number of distinct names which have the string **S** as a **suffix**. The all the letters in the name should contain ***lowercase English alphabets***. **Note: Suffix is an affix occurring at the end of a word, base, or phrase.** Input: -- Input start with test cases **T**. Each test case there is one integer **L** , length of names and a string **S**. Name and string will contain only lowercase letter **‘a’-’z**’. Constrains: -- 1<=T<=10000 1<=L<=100 1<=|S| <= L L-|S|<=10 Output: -- Each case print a single line the total number of names.See the explanation section below for more clarity. Sample Input: -- 3 2 ab 3 ab 4 ab Sample Output -- 1 26 676 **Explanation:** **First case**: There is only one possible name "ab". **Second case**: There is 26 combinations possible, like "aab", "bab", "cab", "dab", "eab", "fab", "gab", "hab", "iab", "jab", "kab", "lab", "mab", "nab", "oab", "pab", "qab", "rab", "sab", "tab", "uab", "vab", "wab", "xab", "yab" & "zab". Every names have "ab" as a suffix and length is 3. **Third case**: Out of 4 place , 2 place are occupied with string "ab". So, there are only 2 places to change and on every place we can place 26 different characters. So total: 26*26=676 ways.


Problem Setter:

Monikrishna Roy

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.50
Go 1.50
Java 1.50
JavaScript 1.50
Objective-C 1.50
Perl 1.50
PHP 1.50
Python 1.50
Python3 1.50
Ruby 1.50
VB.Net 1.50

Problem Stats

238/510

Solve/Submission

Ranking

# User Language Timing
01 fsshakkhor Cpp14 0.00s
02 flash_7 Cpp14 0.00s
03 as_couple Cpp14 0.00s
04 priojeet_priyom Cpp14 0.00s
05 sp_rahul Cpp14 0.00s
06 shihabsarar29 Cpp14 0.00s
07 afzalul Cpp14 0.00s
08 imunir Cpp14 0.00s
09 asad_IT Cpp14 0.00s
10 Mir00r Cpp14 0.00s
11 rabiulrafi01 Cpp14 0.00s
12 askfarid Cpp14 0.00s
13 Masum_ice Cpp14 0.00s
14 feodorv Cpp14 0.00s
15 Morass Cpp14 0.00s
16 Robbinb1993 Cpp 0.00s
17 souravahmed C 0.01s
18 Hawk Cpp 0.01s
19 emrul Cpp14 0.01s
20 prottoy919 Cpp14 0.01s
21 MRoy Cpp14 0.01s
22 arabin Cpp14 0.01s
23 Ssa_AnKan Cpp14 0.01s
24 Emdadul_Hoque Cpp14 0.01s
25 Nazmul_WUB Cpp14 0.01s
26 anik_JU Cpp14 0.01s
27 alhelal_cse Cpp14 0.01s
28 Tanvir_Ahmad Cpp14 0.01s
29 sayedalmahdi Cpp14 0.01s
30 rosudel Cpp14 0.01s
31 MRITuhin Cpp14 0.01s
32 inam Cpp14 0.01s
33 ____ Cpp14 0.01s
34 BlurryFace Cpp14 0.01s
35 rubabredwan Cpp14 0.01s
36 orpib Cpp14 0.01s
37 Rajib_119 Cpp14 0.01s
38 mir003 Cpp14 0.01s
39 I_See_You Cpp14 0.01s
40 samshad Cpp14 0.01s
41 sahedsohel Cpp14 0.01s
42 PKP_007 Cpp14 0.01s
43 Pure_Protea Cpp14 0.01s
44 ssavi Cpp14 0.01s
45 snow_man Cpp14 0.01s
46 Nirjhor Cpp14 0.01s
47 jahid_ict Cpp14 0.01s
48 SakibAlamin Cpp14 0.02s
49 Rajan_sust Cpp14 0.02s
50 ArifKhanShubro Cpp14 0.02s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support