Birthday Numbers II
Time limit1sMemory limit256 MB
Add up the products of every neighboring pair among the integers between x and y that use only the digits 3, 5 and 8, and report the total modulo 19980305.
- Level
Hard8 of 10
- Topics
- Math, Recursion, Combinatorics, String
- Solved
- No attempts yet
Problem
Seunghyun was born on March 5, 1998, so he is very fond of the digits 3, 5 and 8 that appear in his birth date. He decided to call a positive integer a birthday number when its decimal representation consists of the digits 3, 5 and 8 only. For example, 3, 533 and 858553 are birthday numbers, while 3518, 1642 and 88808 are not.
You are given two birthday numbers and (). List every birthday number that is at least and at most in increasing order as , and write a program that computes . Handling huge numbers is always a bother, so print the value modulo , which is Seunghyun's birth date.
Input
The first line contains and the second line contains . Neither line contains any character other than '3', '5' and '8'. ()
Output
Print modulo on the first line.