Please read the new rule regarding the restriction on the use of AI tools. ×

Counting no. of string of size k having m distinct characters

Revision en1, by nilsilu95, 2015-07-02 02:43:12

Given: A strings contains 1 to K lowercase characters and at most M distinct characters.Find total such possible strings

constraints:
1 <= T <= 25
1 <= K <= 10^9
1 <= M <= 26
Sample input
2
1 1
2 10


Sample Output
26
52

https://www.hackerearth.com/code-hack-5/algorithm/incredible-string/
How to approach this problem?

Tags #matrix exponentialtion, #dp

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English nilsilu95 2015-07-02 02:43:12 433 Initial revision (published)