Lucky Tickets
Time limit1sMemory limit128 MB
Count lucky n-digit numbers among k consecutive values starting at a uniformly random s in [a,b], and print the expected count as a fraction.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Combinatorics, Math
- Solved
- No attempts yet
Problem
Egor works as a bus conductor. Every day he receives a pack of tickets to sell, and he always wonders how many of them are lucky, because he believes the more lucky tickets there are, the luckier his day will be.
Each ticket number consists of exactly digits, where is even. A ticket is lucky if the sum of its first digits equals the sum of its last digits.
The first ticket of the pack Egor receives is equally likely to be any integer from to inclusive (uniform distribution). A pack contains tickets with consecutive numbers: if the starting number is , the pack is .
Find the expected number of lucky tickets in tomorrow's pack.
Input
A single line with three integers , , and (, ).
and have the same number of digits, and this number equals the digit count of every ticket. Both values may have leading zeros, and the digit count is taken exactly as written. The number of digits in and is always even.
Output
Print the expected number of lucky tickets in the pack as an irreducible fraction on a single line. If the result is an integer, print just that integer with no slash.