Holi and Friendship

4.5

2 votes
Dynamic Programming, Digit Dp, Algorithms, Medium-Hard, Digit DP, Advanced
Problem

Monk believes in relaxing and playing number games in Holi. Monk's friend defined a Holi function H such that H(x) = sum of digits of number x. Monk is given a question where he will be given a number N and he wants to find the count of number of pairs (x,y) such that the following conditions hold true:

  • 0x<yN
  • H(x)<H(y)
  • H(x)+H(y) is prime

enter image description here

Constraints

1N1050

InputFormat

First line contains N.

OutputFormat

Print the number of pairs modulo 10^9 +7.

Time Limit: 3
Memory Limit: 512
Source Limit:
Explanation

The pairs are (0,2) and (1,2).

Editor Image

?