Блог пользователя anonymous_ali

Автор anonymous_ali, история, 3 месяца назад, По-английски

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.

  • Проголосовать: нравится
  • -16
  • Проголосовать: не нравится

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by anonymous_ali (previous revision, new revision, compare).

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by anonymous_ali (previous revision, new revision, compare).

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by anonymous_ali (previous revision, new revision, compare).

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Why am I getting downvoted? I just wanted some help