Holi and Friendship
Practice
4.5 (2 votes)
Dynamic programming
Digit dp
Algorithms
Medium Hard
Digit dp
Advanced
Problem
48% Success 905 Attempts 50 Points 3s Time Limit 512MB Memory 1024 KB Max Code

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:

  • \(0 \le x < y \le N \)
  • \( H(x) < H(y) \)
  • \( H(x)+H(y) \) is prime

enter image description here

\(Constraints\)

\(1\le N \le 10 ^ {50} \)

\(Input Format \)

First line contains N.

\(Output Format\)

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

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:50
3 votes
Tags:
Dynamic ProgrammingAlgorithmsMedium-HardAdvanced
Points:50
1 votes
Tags:
Dynamic ProgrammingAlgorithmsMedium-HardAdvanced
Points:50
18 votes
Tags:
Dynamic ProgrammingMedium-Hard