#P12284. Mystery of the Heartfelt Numbers

    ID: 14394 Type: Default 1000ms 256MiB

Mystery of the Heartfelt Numbers

Mystery of the Heartfelt Numbers

On a sunny morning, Xiao Lan stepped into his math classroom and was quickly drawn to two lonely numbers x and y written on the blackboard. The math teacher, always fond of clever puzzles, left a mysterious note: hidden within these numbers is a special sentiment. To unveil this mystery, one must select three different positive integers from the range \(1 \sim x\) such that:

  • The remainder when their sum is divided by \(2024\) is \(y\), i.e. \(a+b+c \equiv y \pmod{2024}\).
  • Each of the three numbers does not contain the digits 2 or 4 in its decimal representation.

Note that if reordering the three numbers produces the same combination, it is considered identical. For example, for \(x = 10, y = 9\), both \(1+3+5\) and \(5+3+1\) count as the same combination.

Your task is to help Xiao Lan determine the number of distinct combinations of three valid numbers. Since the answer can be very large, output it modulo \(10^9+7\).

inputFormat

The input consists of a single line with two integers:

  1. x \( (1 \le x)\): the upper bound of the range.
  2. y \( (0 \le y < 2024)\): the required remainder.

Both numbers are separated by a space.

outputFormat

Output a single integer, the number of valid combinations modulo \(10^9 + 7\).

sample

10 9
1