DCP-317: Names-2 Back to All Problems

Medium 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. Thats why he comes to you, and you have to help him. You are given the length of names **L** and a collection of strings **S**. You have to find the number of distinct names which have any string from collection **S** as a suffix. Input: -- Input start with test cases **T**. Each test case first line contains two integer **L** , length of names and **N**, the number of string in collection **S**. Next line contains **N** strings, the collection of strings **S**. Name and strings will contain only lowercase letter **‘a’-’z**’. Constrains: -- 1<=T<=100 1<=L<=100 1<=(|S1|+...+|SN|)<=100 Where |S1| denote the length of string S1 and so on. Output: -- For each case input, output a single line printing the total number of distinct names.<br> Note: The answer may be very large. Use appropriate data type. Sample Input: -- 2 2 2 aa b 3 4 ab bc cd abd Sample Output -- 27 79

Problem Setter:

Monikrishna Roy

Please login to submit solution to this problem.

Problem Limits

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

Problem Stats




# User Language Timing
01 feodorv C 0.00s
02 MRoy Cpp14 0.01s
03 sazal24_7 Cpp 0.03s
04 emotionless Cpp14 0.04s
05 mepromee Cpp 0.05s
06 kissu_pari_na Cpp14 0.05s
07 sdpsarker88 Cpp 0.05s
08 Robbinb1993 Cpp14 0.05s
09 rayhan50001 Cpp 0.07s
10 Durbin Python3 0.12s
11 sayedgkm Cpp14 0.13s
12 Mr_adnan Cpp 0.16s

Your feedback is our precious!

Or call +88 02 9853138 for support