Super Lucky Tickets
Time limit2sMemory limit1024 MB
Count digit strings of even length n where both half sums match and even-position and odd-position sums match, modulo 998244353.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Combinatorics, Math
- Solved
- No attempts yet
Problem
For a spaceship to take off, each crew member needs a ticket. Each ticket has a sequence of digits, where is a positive even number.
Daniil calls a ticket super-lucky if both of the following properties hold:
- The sum of the first digits equals the sum of the last digits.
- The sum of the digits at even positions equals the sum of the digits at odd positions.
Help Daniil count the number of distinct super-lucky tickets modulo .
Input
The first line contains one number , the length of a ticket (). It is guaranteed that is even.
Output
Print the number of super-lucky tickets of length modulo .