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 認為一個數(shù)是有趣的,若這個數(shù)是素數(shù);Asya 認為一個數(shù)是有趣的,當一個數(shù)的約數(shù)個數(shù)為 k ,且 k 是一個素數(shù)。
問在區(qū)間
首先,當一個數(shù)是素數(shù)的時候,這個數(shù)的約數(shù)個數(shù)為 2 (1 和自身),是素數(shù);即兩人必然同時認為一個素數(shù)是有趣的。
之后,考慮合數(shù)的情況。一個數(shù)約數(shù)的個數(shù)可以通過公式快速求得(套質(zhì)因數(shù)分解的板): >=2 時,這個數(shù)的約數(shù)個數(shù)必然是一個合數(shù),則兩人同時認為這個數(shù)不有趣。
因此,只需要判斷一個素數(shù)的任意冪次,當
故預處理出
HINT:由于最大右區(qū)間為
新聞熱點
疑難解答