#C2524. Count Valid Scrabble Words
Count Valid Scrabble Words
Count Valid Scrabble Words
You are given a positive integer n representing the number of distinct characters, a string of n distinct characters, and another positive integer k which is the desired length of the word to form. In this problem, you are required to determine the total number of valid words (arrangements) that can be formed by choosing exactly k characters from the given set without repetition.
The answer is determined by the permutation formula:
$$P(n,k)=\frac{n!}{(n-k)!}$$
If k > n, no valid word can be formed and the answer should be 0.
inputFormat
The input consists of three lines:
- The first line contains an integer n representing the number of distinct characters.
- The second line contains a string of n distinct characters.
- The third line contains an integer k denoting the length of the word to form.
outputFormat
Output a single integer which is the number of valid Scrabble words that can be formed using exactly k characters.
## sample4
abcd
2
12
</p>