Underprime
InterviewTime limit2sMemory limit128 MB
Count integers in a range whose total number of prime factors (with multiplicity) is itself a prime number.
- Level
Easy3 of 10
- Topics
- Number theory, Math, Implementation
- Solved
- No attempts yet
Problem
When a positive integer X is factorized into primes, we get a list of prime numbers whose product is X. For example, 12 factors as 2 × 2 × 3, so the list has length 3. The number 1 is not prime.
A number X is called an underprime if the length of this prime-factor list is itself prime. Since 12 has a list length of 3 and 3 is prime, 12 is an underprime.
Given two integers A and B, count how many integers from A through B, inclusive, are underprimes.
Input
The first line contains two integers A and B.
Output
Print the number of underprimes greater than or equal to A and less than or equal to B.
Constraints
- 2 ≤ A ≤ B ≤ 100,000