Kilk
Time limit2sMemory limit512 MB
Count the strings with x letters a and y letters b whose longest run of equal letters is as small as possible, modulo 998244353.
- Level
Medium6 of 10
- Topics
- Combinatorics, Math, String
- Solved
- No attempts yet
Problem
Find the number of strings that consist of letters a and letters b, such that the length of the longest substring of equal letters is as small as possible among all such strings. Display the count modulo .
Input
The first line contains a single integer (), the number of test cases. Each of the next lines contains two integers and ().
Output
For each test case, print the required number.
Hint
In the first test case, the strings are abbabb, bababb, babbab, bbaabb, bbabab, and bbabba. Each of these strings has a longest run of equal letters of length 2, and no string with 2 letters a and 4 letters b has a smaller value.