String Construction
InterviewTime limit1sMemory limit1024 MB
Count the pairs of length-N uppercase strings whose longest common subsequence made only of 'A' has length exactly M, modulo 998244353.
- Level
Medium4 of 10
- Topics
- Math, Combinatorics, Implementation
- Solved
- No attempts yet
Problem
Using uppercase English letters, build two strings and of length .
For a string , a subsequence is a new string made by deleting zero or more characters from . A string that is a common subsequence of and and consists only of A is called a common A-subsequence. Count the number of ways to build and so that the longest common A-subsequence has length exactly .
Input
The first line contains two integers and , separated by a space.
Output
On the first line, print the answer modulo .