PR Numbers
Practice
3.9 (18 votes)
Dynamic programming
Gcd
Dp on digits
Digit dp
Greatest common divisor
Medium
Algorithms
Easy Medium
Digit dp
Arithemtic operations
Greatest common divisor
Dynamic programming
Problem
30% Success 5961 Attempts 30 Points 1s Time Limit 500MB Memory 1024 KB Max Code
You are given \(2\) integers \(L\) and \(R\). You are required to find the count of all the PR numbers in the range \(L\) to \(R\) inclusively. PR number are the numbers which satisfy following \(2\) properties: -
\(P\) :- No pair of adjacent digits are coprime i.e. \(2\) adjacent digits in a PR number will not be coprime to each other.
\(R\) :- PR number is divisible by all the single digit prime numbers which occur as a digit in the PR number.
Input Format
The first line contains \(2\) space seperated integers \(L\) and \(R\) (\(1 \le L,R \le 10^{18}\)).
Output Format
Print answer for each test case in a new line.
Submissions
Please login to view your submissions
Similar Problems
Points:30
508 votes
Tags:
Dynamic ProgrammingApprovedEasy-Medium
Points:30
7 votes
Tags:
AlgorithmsApprovedEasy-MediumDynamic programming
Points:30
50 votes
Tags:
Applications of Dynamic ProgrammingAlgorithmsDynamic Programming
Editorial