Serious Business
Time limit3sMemory limit1024 MB
Count the integers in [L, R] whose number of even-digit-sum contiguous substrings is odd, modulo 998244353, with R up to 100000 digits.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Prefix sum, String, Math
- Solved
- No attempts yet
Problem
As the proprietor of a Serious Business, you handle a lot of serial numbers. Each gadget, gizmo, and thingamajig you manufacture has a unique serial number. Each serial number is a sequence of decimal digits with no leading zeros.
You are extremely superstitious, however, and you only put lucky serial numbers on your products. A serial number is lucky if it has an odd number of scary contiguous substrings. A contiguous substring is scary if the sum of its digits is even.
An auditor asked how many gadgets, gizmos, and thingamajigs you manufactured last year, but you cannot remember. You only know that every serial number you used was between and inclusive (interpreted as decimal numbers), and that you used every lucky serial number in that range. How many such serial numbers are there? Since the answer may be very large, output it modulo the prime .
Input
There are two lines of input. The first contains and the second contains , which are integers with no leading zeros. It is guaranteed that .
Output
Output a single integer, the number of lucky serial numbers between and , modulo .