I was asked this problem in an Online assessment. Can someone help me with this problem↵
## Problem Statement↵
↵
You are given two integers n and k. ↵
Count the number of distinct strings of length n consisting of lowercase Latin letters such that the number of equal consecutive characters is strictly less than k.↵
↵
### Constraints↵
↵
- 1 ≤ n ≤ 100000 ↵
- 1 ≤ k ≤ n↵
↵
#### Input↵
↵
Two integers n and k.↵
↵
#### Output↵
↵
Print the number of valid strings of length n.↵
↵
### Examples↵
↵
#### Example 1↵
↵
Input ↵
3 3↵
Output ↵
17550↵
↵
Explanation ↵
The total number of strings of length 3 over lowercase Latin letters is 26³ = 17576. ↵
There are exactly 26 strings with three equal consecutive characters (aaa, bbb, etc.). ↵
Hence, the answer is 17576 − 26 = 17550.↵
↵
#### Example 2↵
↵
Input ↵
3 2↵
Output ↵
16250↵
↵
Explanation ↵
The total number of strings of length 3 is 26³ = 17576. ↵
↵
Invalid strings are:↵
- Strings with exactly two equal consecutive characters: 26 × 25 + 26 × 25↵
- Strings with three equal consecutive characters: 26↵
↵
Total invalid strings = 1326. ↵
Therefore, the number of valid strings is 17576 − 1326 = 16250.
## Problem Statement↵
↵
You are given two integers n and k. ↵
Count the number of distinct strings of length n consisting of lowercase Latin letters such that the number of equal consecutive characters is strictly less than k.↵
↵
### Constraints↵
↵
- 1 ≤ n ≤ 100000 ↵
- 1 ≤ k ≤ n↵
↵
#### Input↵
↵
Two integers n and k.↵
↵
#### Output↵
↵
Print the number of valid strings of length n.↵
↵
### Examples↵
↵
#### Example 1↵
↵
Input ↵
3 3↵
Output ↵
17550↵
↵
Explanation ↵
The total number of strings of length 3 over lowercase Latin letters is 26³ = 17576. ↵
There are exactly 26 strings with three equal consecutive characters (aaa, bbb, etc.). ↵
Hence, the answer is 17576 − 26 = 17550.↵
↵
#### Example 2↵
↵
Input ↵
3 2↵
Output ↵
16250↵
↵
Explanation ↵
The total number of strings of length 3 is 26³ = 17576. ↵
↵
Invalid strings are:↵
- Strings with exactly two equal consecutive characters: 26 × 25 + 26 × 25↵
- Strings with three equal consecutive characters: 26↵
↵
Total invalid strings = 1326. ↵
Therefore, the number of valid strings is 17576 − 1326 = 16250.



