Easy Beginners Problems > Ad-hoc

Today is the first day of new year 2018.So, brilliant boy **Mahammad** learned few string matching algorithms, Mahammad is now ready to practice. Today, his teacher gave him a simple task to solve. Teacher provided two strings of length **N** and **M**, respectively. Then, **Q** queries are followed, which asks to count the number of substrings of the first string of length L which are also substring of the second string. Note that, substring means a contiguous part of the string. Input: ------ Input starts with an integer **T (1 <= T <= 10)**, denoting the number of test cases. Each case starts with two integer **N ,M (1 ≤ N, M ≤ 45)** denoting the lengths of the two strings. The next two lines contain the first and second strings consisting only lowercase English letters, respectively. The forth line contains one integer **Q (1 ≤ Q ≤ 50)** indicating the number of queries which the teacher asks. The last **Q** lines, will have one positive integer **L (1 <= L <= 50)** each showing the the length of substrings which you need to process. Output: ------- For each of the queries, print the number of desired substrings. Sample Input ------------ 3 5 4 hello hell 4 1 2 3 4 6 6 peyser xeyyam 4 1 2 3 4 5 7 happy newyear 2 1 2 Sample Output ------------- 4 3 2 1 3 1 0 0 2 0 For the first query of the first test case "h", "e", "l", "l" satisfy the condition.

Mahmud Allahverdiyev

Language |
Time Limit (seconds) |

C | 2.00 |

C++ | 2.00 |

C++14 | 2.00 |

C# | 3.00 |

Go | 3.00 |

Java | 3.00 |

JavaScript | 3.00 |

Objective-C | 3.00 |

Perl | 3.00 |

PHP | 3.00 |

Python | 3.00 |

Python3 | 3.00 |

Ruby | 3.00 |

VB.Net | 3.00 |

Solve/Submission

# | User | Language | Timing |
---|---|---|---|

01 | Taran | Cpp14 | 0.00s |

02 | lsiddiqsunny | Cpp | 0.00s |

03 | pulak_ict_mbstu | Cpp | 0.00s |

04 | anik_JU | Cpp | 0.00s |

05 | monir769 | Cpp14 | 0.00s |

06 | by_default | Cpp | 0.00s |

07 | Ryuuk | Cpp | 0.00s |

08 | swapnil | Cpp | 0.00s |

09 | mir003 | Cpp | 0.00s |

10 | _GhOstMan_ | Cpp | 0.00s |

11 | abu_rifat | Cpp | 0.00s |

12 | AlaminJust | Cpp | 0.00s |

13 | mehedi_01 | Cpp14 | 0.00s |

14 | mepromee | Cpp | 0.00s |

15 | soohotiam | Cpp | 0.00s |

16 | unknown420 | Cpp | 0.00s |

17 | Indrjit_BU | Cpp | 0.00s |

18 | nymphaea | Cpp | 0.00s |

19 | hmsayem | Cpp14 | 0.00s |

20 | ss1230 | Cpp | 0.00s |

21 | Sagor | Cpp | 0.00s |

22 | FariD | Cpp14 | 0.00s |

23 | mahade31 | Cpp14 | 0.00s |

24 | feodorv | C | 0.00s |

25 | The_Musketeer | Cpp14 | 0.00s |

26 | Riaz_BSMRSTU | Cpp | 0.01s |

27 | daihan_mbstu | Cpp | 0.01s |

28 | Foysol_Ahmed | Cpp | 0.01s |

29 | jayed_al_hasan | Cpp | 0.01s |

30 | pin2paul | Cpp | 0.01s |

31 | mhiceiuk | Cpp | 0.01s |

32 | orpib | Cpp | 0.01s |

33 | loser_123 | Cpp14 | 0.01s |

34 | mbstu_nitai | Cpp | 0.01s |

35 | Sajal_Deb | Cpp | 0.01s |

36 | iamsadee | Cpp | 0.01s |

37 | Biprodas | Cpp14 | 0.01s |

38 | Dhrubo020 | Cpp | 0.01s |

39 | sdpsarker88 | Cpp14 | 0.01s |

40 | ssavi | Cpp | 0.01s |

41 | Anikcsejnu | Cpp | 0.01s |

42 | showmic | Cpp14 | 0.01s |

43 | Silent_Warrior | Cpp | 0.01s |

44 | tariqiitju | Cpp14 | 0.01s |

45 | sazal24_7 | Cpp | 0.01s |

46 | cse_nazmul | Cpp | 0.01s |

47 | prodipdatta7 | Cpp | 0.01s |

48 | subhashis_cse | Cpp | 0.01s |

49 | mhiceiu | Cpp | 0.01s |

50 | RAJ0RSHI | Cpp | 0.01s |

Copyright © 2015-2016 Dev Skill.

Feedback
#### Your feedback is our precious!

## Thank you for providing feedback! Our developers will be happy :)

## Sorry there was a problem when submitting the feedback. Please try again. :(