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




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

Your feedback is our precious!

Or call +88 02 9853138 for support