#SP0000095. Mặt nạ nguyên tố (Prime Mask)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Mặt nạ nguyên tố (Prime Mask)
Prime Mask
Source: LQDOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Consider a positive integer . Let denote the distinct prime divisors of , listing each prime divisor exactly once. Define:
The number is valid if and only if all three conditions hold:
- : has at least two distinct prime divisors.
- is divisible by .
- The quotient is a prime number.
The exponents in the prime factorization of do not change or : each distinct prime divisor is counted exactly once.
Given two integers , count the valid integers in the inclusive range .
Input
A single line containing two integers and , the endpoints of the query interval.
Output
Print one integer: the number of valid numbers in the inclusive interval .
Subtasks
- Subtask 1 (50 points): .
- Subtask 2 (50 points): .
Examples
Example 1
Input
1 30
Output
1
Explanation
In , has distinct prime divisors . Thus , , and , which is prime. No other number in the interval satisfies all three conditions, so the answer is .
Example 2
Input
30 30
Output
1
Explanation
The interval contains only the number . As verified in Example 1, it meets all three conditions, hence the answer is .
Example 3
Input
1 1000
Output
40
Explanation
For , , , and is prime. The number has the same distinct prime divisors , so , , and : it is also valid. For , we get , , and , which is prime.
Checking the remaining integers similarly, the complete list of valid values in the interval is:
30 60 70 90 105 120 140 150 180 231
240 270 280 286 300 315 350 360 450 480
490 525 540 560 572 600 627 646 693 700
720 735 750 805 810 897 900 945 960 980
There are exactly values in the list, so the output is 40.