Nikolay and Asya investigate integers together in their spare time. Nikolay thinks an integer is interesting if it is a PRime number. However, Asya thinks an integer is interesting if the amount of its positive divisors is a prime number (e.g., number 1 has one divisor and number 10 has four divisors).
Nikolay and Asya are happy when their tastes about some integer are common. On the other hand, they are really upset when their tastes differ. They call an integer satisfying if they both consider or do not consider this integer to be interesting. Nikolay and Asya are going to investigate numbers from segment [L, R] this weekend. So they ask you to calculate the number of satisfying integers from this segment.
In the only line there are two integers L and R (
In the only line output one integer — the number of satisfying integers from segment [L, R].
Nikolay 认为一个数是有趣的,若这个数是素数;Asya 认为一个数是有趣的,当一个数的约数个数为 k ,且 k 是一个素数。
问在区间
首先,当一个数是素数的时候,这个数的约数个数为 2 (1 和自身),是素数;即两人必然同时认为一个素数是有趣的。
之后,考虑合数的情况。一个数约数的个数可以通过公式快速求得(套质因数分解的板): >=2
时,这个数的约数个数必然是一个合数,则两人同时认为这个数不有趣。
因此,只需要判断一个素数的任意幂次,当
故预处理出
HINT:由于最大右区间为
新闻热点
疑难解答